open my $fh, '<', $path or die $!; my @first5; for (1 .. 5) { defined( my $line = <$fh> ) or last; push @first5, $line; }