in reply to Extract Multiple Lines from the End of a multi-line string
sub Last_N_Lines { my ($String, $N) = @_; my @ret; open(my $IN, "<", \$String); while (<$IN>) { push(@ret, $_); shift(@ret) if $. > $N } return join "", @ret; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extract Multiple Lines from the End of a multi-line string
by ikegami (Patriarch) on Oct 17, 2008 at 16:56 UTC |