Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: remove blank lines with regex

by jeffenstein (Hermit)
on May 21, 2002 at 12:59 UTC ( [id://168107]=note: print w/replies, xml ) Need Help??


in reply to remove blank lines with regex

There isn't the s flag for the first regex. This will prevent the second from ever being run. For that matter, you can replace the entire while(){} with this regex:

$lines =~ s/\n+/\n/gs;

Replies are listed 'Best First'.
Re: Re: remove blank lines with regex
by perlplexer (Hermit) on May 21, 2002 at 13:22 UTC
    FYI
    the /s flag only matters if you have '.' in your regex.
    So, /\n\n/ will work just as good as /\n\n/s
    From perlre
    ... s Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it would not match. ...
    --perlplexer

Log In?
Username:
Password:

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

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

    No recent polls found