in reply to newlines in regular expressions
The keys as it were are to note that \n\n is a blank line or if you read a file line by line then a blank line will match m/^\s*$/
perl -pi.bak -e 's/\n{2,}/\n/' file.txt
perl -pi -e 's/^\s*\z//' file.txt perl -ne 'print unless m/^\s*$/' file.txt > noblanks.txt
Update
Updated as per sgifford's comments.
cheers
tachyon
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: newlines in regular expressions
by sgifford (Prior) on Dec 07, 2004 at 06:57 UTC | |
by eyepopslikeamosquito (Bishop) on Dec 07, 2004 at 07:22 UTC | |
by tachyon (Chancellor) on Dec 07, 2004 at 12:09 UTC | |
by tachyon (Chancellor) on Dec 07, 2004 at 11:59 UTC |
In Section
Seekers of Perl Wisdom