poj#!perl use strict; my $infile = $ARGV[0]; my $outfile = $ARGV[1]; unless (@ARGV==2) { die "Usage : perl $0 infile outfile\n" }; open IN, '<',$infile or die "Could not open $infile : $!\n"; open OUT,'>',$outfile or die "Could not open $outfile : $!\n"; my @hdr; my $count_in; my $count_out; while (<IN>){ ++$count_in; my @f = split; if (@f<3){ @hdr = @f; } else { print OUT "@hdr $_"; ++$count_out; } } print "$count_in lines read from $infile\n"; print "$count_out lines written to $outfile\n"; close IN; close OUT;
In reply to Re^3: Insert Text which is Read from the Line Above
by poj
in thread Insert Text which is Read from the Line Above
by jlb333333
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |