summaryrefslogtreecommitdiff
path: root/os2/perl2cmd.pl
diff options
context:
space:
mode:
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;
}