summaryrefslogtreecommitdiff
path: root/os2/perl2cmd.pl
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2003-10-29 06:00:18 -0800
committerNicholas Clark <nick@ccl4.org>2003-11-02 18:22:16 +0000
commit59ad941d06909cf9027c5fb10edca7d68fc7149b (patch)
tree31cbe92fcf6d4df0a555139b93ead70dafd6824d /os2/perl2cmd.pl
parentdf500c58e3444bfdd2437855ea268d802281b50e (diff)
downloadperl-59ad941d06909cf9027c5fb10edca7d68fc7149b.tar.gz
OS/2 build
Message-ID: <20031029220017.GA26384@math.berkeley.edu> p4raw-id: //depot/perl@21620
Diffstat (limited to 'os2/perl2cmd.pl')
-rw-r--r--os2/perl2cmd.pl19
1 files changed, 15 insertions, 4 deletions
diff --git a/os2/perl2cmd.pl b/os2/perl2cmd.pl
index f9cc03bdac..4db40a0a31 100644
--- a/os2/perl2cmd.pl
+++ b/os2/perl2cmd.pl
@@ -16,14 +16,25 @@ EOU
$idir = $Config{installbin};
$indir =~ s|\\|/|g ;
+my %seen;
+
foreach $file (<$idir/*>) {
- next if $file =~ /\.exe/i;
+ next if $file =~ /\.(exe|bak)/i;
$base = $file;
$base =~ s/\.$//; # just in case...
$base =~ s|.*/||;
- $file =~ s|/|\\|g ;
+ $base =~ s|\.pl$||;
+ #$file =~ s|/|\\|g ;
+ warn "Clashing output name for $file, skipping" if $seen{$base}++;
print "Processing $file => $dir\\$base.cmd\n";
- system 'cmd.exe', '/c', "echo extproc perl -S>$dir\\$base.cmd";
- system 'cmd.exe', '/c', "type $file >> $dir\\$base.cmd";
+ open IN, '<', $file or warn, next;
+ open OUT, '>', "$dir/$base.cmd" or warn, next;
+ my $firstline = <IN>;
+ my $flags = '';
+ $flags = $2 if $firstline =~ /^#!\s*(\S+)\s+-([^#]+?)\s*(#|$)/;
+ print OUT "extproc perl -S$flags\n$firstline";
+ print OUT $_ while <IN>;
+ close IN or warn, next;
+ close OUT or warn, next;
}