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