Anish Kumar K. wrote:
Hi

Hello,

This program I use to get the last line from the log file "cipe.log".
and then write the line onto a text file "a.txt"

system("tail -1 cipe.log > a.txt");
open INPUT,"a.txt";
my $line=<INPUT>;

then I open the text file and read the value from the file handle.

This invloves cumbersome process. I need to avoid writing to a file the
o/p of the system command. Is there a way to assign to some variable...

Use the File::ReadBackwards module: http://search.cpan.org/~uri/File-ReadBackwards-1.03/




use File::ReadBackwards

my $bw = File::ReadBackwards->new( 'cipe.log' )
    or die "Cannot read 'log_file' $!";

my $line = $bw->readline;




John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to