@REM=(" @c:\bin\perl.exe c:\bin\%0.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9 @goto end ") if 0; # This is where the perl program goes # initialize if (!@ARGV) { die "\n$0: Usage: $0 [] [..]\n"; } foreach $file (@ARGV) { if (!-e $file) { print STDERR "File $file not found\n"; } else { ($fname, $type) = ($file =~ /^([^.]+)\.?(.*)$/); push(@INFILES, $file); push(@INNAMES, $fname); } } print STDERR "@INFILES\n"; foreach $file (@INFILES) { $fname = shift @INNAMES; open (FILE,"<$file") || die "Can't open $file $!\n"; print STDOUT "\nReading input file: $file\n"; open (OUTPUT,">$fname.out") || die "Can't open output file $fname.out\n"; print STDERR "Writing file $fname.out\n"; select(STDOUT); $splitpt = 0; $echo = 1; # echo lines until find #split: while (){ # look for begin and end of a split block if (/^\s*#split/i) { $echo = 0; s/\t/ /g; $splitpt = index($_,'|'); if ($splitpt < 0) {die "Bad splitline : $_";} next; } if (!$echo) { s/\t/ /g; if (/^\s*#unsplit/) { $echo = 1; foreach $first (@first) { $first =~ s/\n//; print OUTPUT "$first\n"; } foreach $second (@second) { print OUTPUT "$second"; } @first = ''; @second = ''; next; } push(@first, substr($_,0,$splitpt)); push(@second, substr($_,$splitpt)); } else { print OUTPUT $_; } } close(OUTPUT); } @REM=(" :end ") if 0;