I'm looping through a file (each line) and i'm wanting to take out the last '|'. Just wondering whats the quickest way as the file can be over a million lines.
my $infile = 'infile.txt';
my $outfile = 'outfile.txt';
[tt]
open (INFILE, $infile) or die "Couldn't open $infile : $!\n";
open (OUTFILE, ">$outfile" or die "Couldn't open $outfile : $!\n";
while (<INFILE>) {
#remove any newline charachters
chomp;
#remove the last charachter
chop;
print OUTFILE $_;
}
close (INFILE);
close (OUTFILE);
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.