sub Last_N_Lines { my($String, $N) = @_; my $re = '^' . ( '.*\\n' x ($N-1) ) . '(?:.*\\n|.+)'; return ( $String =~ /($re)\z/ )[0]; }