Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: trim the blank lines...regex

by wade (Pilgrim)
on Apr 11, 2008 at 19:37 UTC ( [id://679828]=note: print w/replies, xml ) Need Help??


in reply to trim the blank lines...regex

I'm a little afraid of answering this 'cause it looks a bit like homework. That said...

The first question I have is "how did you get the string in the first place?" The answer to this might present a better solution (e.g., don't concatenate blank lines to $str in the firs place).

To answer your original question, though:

use strict; use warnings; use diagnostics; print "START: '$str'"; $str =~ s/\n\n+/\n/g; print "\nEND: '$str'";
--
Wade

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found