Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: remove blank lines with regex

by broquaint (Abbot)
on May 21, 2002 at 12:52 UTC ( [id://168103]=note: print w/replies, xml ) Need Help??


in reply to remove blank lines with regex

Try adding the s modifier to the regex match in the while loop. Also you might want to use $/ instead of a literal \n as it's more portable. Although this code should do the job without having to loop through the string.
$lines =~ s{$/$/}{$/}gs;

HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found