Help for this page

Select Code to Download


  1. or download this
    my @lastmatches;
    my $keep = 5;
    ...
        push @lastmatches, $line;
        unshift @lastmatches if --$keep < 1;
    }
    
  2. or download this
    my @lastfive = ( grep { /criteria/ } <FILEHANDLE> ) [ -5 .. -1 ];
    
  3. or download this
    use strict;
    use warnings;
    ...
    close IN;
    my $count = 5;
    print $count--, ".: ", $_ foreach @lastfive;