in reply to print last line
G'day httpd,
It's unlikely that you really want a regex; however, if you do, here's one way to do it:
$ cat pm_1027453.dat line1 line2 line3
$ perl -Mstrict -Mwarnings -E ' say do { local $/; <> } =~ /(.*)\Z/m; ' pm_1027453.dat line3
You've already been given non-regex solutions. Here's another using Tie::File:
$ perl -Mstrict -Mwarnings -E ' use Tie::File; tie my @lines, q{Tie::File}, q{./pm_1027453.dat} or die $!; say $lines[$#lines]; untie @lines; ' line3
You may want to look at Benchmark to see which solution best suits your application.
-- Ken
|
|---|