3 # Expand include files in praat script.
4 # Writes the expanded script to STDOUT.
5 # Concatenates all arguments.
8 # perl expandPraatScripts.pl <file1> ...
12 foreach my $input (@ARGV)
17 sub expand
# (filename)
20 my $directory = `dirname $filename`;
22 open(FILE
, "<$filename") || die "$!: $filename\n";
23 my @CurrentScript = <FILE
>;
25 foreach my $line (@CurrentScript) {
26 if($line =~ /^([^\#]*)include\s+(\S+)/){
27 my ($previous, $match, $following) = ($1, $2, $');
28 print "$previous\n" if $previous =~ /\S/;
29 # Insert included file
30 expand("$directory/$match");
31 print "$following" if $following =~ /\S/;
44 open(HEAD, "<../.git/HEAD");
47 if($headRef =~ /^\s*ref\:\s+/){
50 open(HEAD
, "<../.git/$refPtr");
53 $headSHA = uc(substr($headSHA, 0, 10));
58 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime();
60 ${mon
} = sprintf("%02d",${mon
}+1);
61 ${mday
} = sprintf("%02d",${mday
});
62 ${hour
} = sprintf("%02d",${hour
});
63 ${min
} = sprintf("%02d",${min
});
64 ${sec
} = sprintf("%02d",${sec
});
65 $UTCstring = "${year}-${mon}-${mday}T${hour}:${min}:${sec}Z";
66 print "\nbuild_SHA\$ = \"$headSHA $UTCstring\"\n";