Getting syntax error in perl script

252 views Asked by At

I am trying to run the script you see in this answer:

best way to add license section to iOS settings bundle

And I am getting a syntax error in Xcode.

Missing right curly or square bracket at ./acknowledgements.pl line 57, at end of line
syntax error at ./acknowledgements.pl line 57, at EOF
Execution of ./acknowledgements.pl aborted due to compilation errors.
Command /bin/sh failed with exit code 255

Not sure why it is happening.

Here is the script from my machine:

#!/usr/bin/perl -w

use strict;

my $out = "../Settings.bundle/en.lproj/Acknowledgements.strings";
my $plistout =  "../Settings.bundle/Acknowledgements.plist";

unlink $out;

open(my $outfh, '>', $out) or die $!;
open(my $plistfh, '>', $plistout) or die $!;

print $plistfh <<'EOD';
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>PreferenceSpecifiers</key>
<array>
EOD

for my $i (sort glob("*.license")){

    my $value=`cat $i`;
    $value =~ s/\r//g;
    $value =~ s/\n/\r/g;
    $value =~ s/[ \t]+\r/\r/g;
    $value =~ s/\"/\'/g;
    my $key=$i;
    $key =~ s/\.license$//;

    my $cnt = 1;
    my $keynum = $key;
    for my $str (split /\r\r/, $value){

        print $plistfh <<"EOD";
        <dict>
        <key>Type</key>
        <string>PSGroupSpecifier</string>
        <key>FooterText</key>
        <string>$keynum</string>
        </dict>
        EOD

        print $outfh "\"$keynum\" = \"$str\";\n";
        $keynum = $key.(++$cnt);
     }
}

print $plistfh <<'EOD';
</array>
</dict>
</plist>
EOD
close($outfh);
close($plistfh);
1

There are 1 answers

0
Neil H Watson On BEST ANSWER

I believe that the heredoc terminator (EOD) cannot be preceded by whitespace. Remove the indentation and try again.