http://www.perlmonks.org?node_id=1090417

mitchreward has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys,

Am pretty new to perl and wanted to export the last value of $last. But it doesn't work. Could you help?

ps: I just wanted to make the equivalent of a Unix "tail -1"

use CGI qw(:standard); use strict; use utf8; my $srce = "/some/file"; my $string1 = "some-regex"; my $last; open my $fh, $srce or die "Could not open $scre: $!"; my @lines = grep /\Q$string1/, <$fh>; foreach my $line (@lines) { my @fields = split /\s+/, $line; $last= $fields[3]; } print "$last";
thanks