use strict; use warnings; use 5.010; open my $fh, '<', 'path/to/my/file.csv' or die "Could not open file: $!"; my @whole_file = <$fh>; say 'Number of lines:', scalar @whole_file;