use File::Slurp qw( slurp ); my $str = slurp('file'); $str =~ s/\n//g;