Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How do I remove blank lines from text files?

by davorg (Chancellor)
on Jul 10, 2000 at 21:43 UTC ( #21832=note: print w/replies, xml ) Need Help??


in reply to How do I remove blank lines from text files?

Depends what exactly you mean by a 'blank line'. Assuming that you mean a line that contains only white space characters then you can do something like this:

while (<>) { print if /\S/; }

And you can do the same thing from the command line

perl -i.bak -n -e "print if /\S/" filename
--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>

Replies are listed 'Best First'.
Re^2: How do I remove blank lines from text files?
by 92sai (Novice) on Jun 18, 2015 at 09:09 UTC
    how to remove blank lines in an xml file after modifying it??

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21832]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2020-10-21 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (212 votes). Check out past polls.

    Notices?