Am Dienstag, 15. März 2005 01.33 schrieb Anish Kumar K.: > Hi > > 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...
Here an easy way: use strict; use warnings; my $line; open FILE, "<", 'cipe.log' or die "error opening file: $!"; $line=$_ while <FILE>; # copies each line to $line :-( close FILE or warn "error closing file: $!"; print $line; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>