use Tie::File; my @array; tie @array, 'Tie::File', filename or die ...; if ( $array[-1] =~ /regex here/ ) { # print elemeents -10 to -1. }