#!/usr/bin/perl use strict; use warnings; use Perl6::Slurp; # generate test file "le.txt" my $win_line = "Windows\r\n"; my $unix_line = "Unix\n"; my $mac_line = "Mac\r"; open(my $fh, ">", "le.txt"); binmode($fh); print $fh $win_line; print $fh $unix_line; print $fh $mac_line; close($fh); # read file with slurp my @lines = slurp("le.txt", {chomp => 1, irs => qr/(\r\n)|(\n)|(\r)/}); for my $line (@lines) { print $line . "\n"; } #### # read file my $file_content; { local $/ = undef; # no input data record separator --> file content will be stored in one scalar open(my $fh, "<", "le.txt"); binmode($fh); $file_content = <$fh>; close($fh); } (my $space_file_content = $file_content) =~ s/(\r\n)|(\n)|(\r)/ /g; for my $line (split(/ /, $space_file_content)) { print $line . "\n"; }