Bit of a different way:
open my $fh, '<', $filename or die "Can't open file: $!"; my $line = do { local $/; <$fh> }; $line =~ s/\n*\n/ /g;
There's also File::Slurp.
Edit: changed \n?\n to \n*\n to catch multiple consecutive blank lines.
In reply to Re: read file into 1 line string
by stevieb
in thread read file into 1 line string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |