Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Re: removing blank lines from files

by mirod (Canon)
on Jun 20, 2002 at 13:35 UTC ( [id://176005]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: removing blank lines from files
in thread removing blank lines from files

Actually Perl DWIMs properly here, and /^\s+$/ catches empty lines. The $ is quite magic, if the \n at the end of the string/line is matched then $ matches the empty end-of-string, if the \n is not matched then $ matches it, plus the end-of-string.

You can test it with this code:

my $string="12\n"; print 'matches ^\d+\n$' . "\n" if( $string=~ /^\d+\n$/); print 'matches ^\d+$' . "\n" if( $string=~ /^\d+$/);

Log In?
Username:
Password:

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

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

    No recent polls found