my $data = do { local $/; }; @array = split 'on something', $data; #### while ( my $line = ) { # handle the line here instead of as an element of an array } #### use Path::Tiny 'path'; my $file_path = '/foo/bar/baz.txt'; # if no memory concern, slurp: my @lines = path( $file_path )->lines_utf8({chomp => 1}); # or read from a filehandle line-by-line: my $fh = path( $file_path )->openr_utf8; while ( my $line = <$fh> ) { chomp $line; ... }