Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Perl one liner

by viktor (Acolyte)
on Aug 08, 2011 at 19:40 UTC ( #919311=perlquestion: print w/replies, xml ) Need Help??
viktor has asked for the wisdom of the Perl Monks concerning the following question:

Is there a one liner to merge say three new lines (blank lines )in one new (blank) line in perl.

Replies are listed 'Best First'.
Re: Perl one liner
by JavaFan (Canon) on Aug 08, 2011 at 20:02 UTC
    perl -i -0777 -pe 's/\n\n\n/\n/g' your-file
Re: Perl one liner
by BrowserUk (Pope) on Aug 08, 2011 at 19:55 UTC

    C:\test>type junk.dat 1 2 3 4 5 C:\test>perl -00 -pe1 junk.dat > junk.out C:\test>type junk.out 1 2 3 4 5

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Perl one liner
by Anonymous Monk on Aug 08, 2011 at 19:44 UTC
    No, you'll have to write it :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://919311]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-08-18 23:58 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (310 votes). Check out past polls.