in reply to Re: Re: search and replace last line
in thread search and replace last line

If you don't want to do the traditional approach of buffering and re-writing the data yourself, you can try Tie::File. A small example using your test data:

#!/usr/bin/perl -wd use Tie::File; tie @array, 'Tie::File', "test.txt" or die "cannot tie file\n"; ($date,$data) = split( /\s+/, $array[-1] ); $data = "whatever" if $date eq "200208"; $array[-1] = "$date $data"; untie @array;

-derby