in reply to Can't remember the term to search for help on!
You are thinking of 'file slurping' - which is done by modifying the $/ perl line separator (use $/ = undef; to slurp in one go), or using a module like File::Slurp.
Then you can use a regex to remove single newline characters, but leave alone double ones using a lookahead assertion, or something simple like:
use strict; use warnings; my $line = "foo\nbar\n\nbaz"; print "Before :\n \'$line\'\n"; #Before : #'foo #bar # #baz' $line =~ s/\n([^\n])/$1/; print "after : \'$line\'\n"; #after : #'foobar # #baz'
HTH!
|
|---|