P is for Practical | |
PerlMonks |
Re: One-liner removes whitespace-only lines from text fileby FoxtrotUniform (Prior) |
on Dec 19, 2001 at 02:21 UTC ( [id://132956]=note: print w/replies, xml ) | Need Help?? |
This snippet removes all non-empty lines containing only whitespace, but I don't think that's particularly intuitive behaviour. If I want to remove all "blank" lines from a file, I probably want:
and if I want to get rid of all the lines with "useless" whitespace, I probably want to collapse them to empty lines:
Update: Changed first one-liner to Ovid's for readability. --:wq
In Section
Cool Uses for Perl
|
|