in reply to Extract Multiple Lines from the End of a multi-line string

sub Last_N_Lines { my ($str, $n) = @_; return join "\n", grep {defined} (split "\n", $str)[-$n .. -1]; }

Perl reduces RSI - it saves typing