open ($entry_file, '<', "$directory/$entry") or die "$entry_file $!"; my @first5 = (<$fh>)[0 .. 4]; for (1 .. 5) { defined( my $line = <$fh> ) or last; push @first5, $line; }