Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-10-01 21:20 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (7 votes). Check out past polls.