in reply to What’s the best way to get the last N elements of a Perl array?

I've not tested it, but I usually use something like this:
use List::Util qw(max); @last_n = @source[max(0, @source - $n) .. $#source];

Update: Fixed offby1-error pointed out by AnomalousMonk++

  • Comment on Re: What’s the best way to get the last N elements of a Perl array?
  • Download Code