If we want to print last line of any file, we can use the following code.
use strict; use warnings; # open the file using _ to avoid multiple system calls invoked by perl open _,"filename"; # reading all lines from a file and store it into @lines array my @lines=<_>; # printing the last line of a file in @lines by $#lines => last index +of the array print @lines[$#lines];
In reply to Re: Printing Last Element of a line using perl memory?
by nvivek
in thread Printing Last Element of a line using perl memory?
by symgryph
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |