in reply to read file into 1 line string
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: read file into 1 line string
by jwkrahn (Abbot) on Apr 22, 2012 at 03:48 UTC |