Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: perl regular expressions and empty strings unexpected results

by moritz (Cardinal)
on Jan 23, 2012 at 09:44 UTC ( #949345=note: print w/replies, xml ) Need Help??


in reply to perl regular expressions and empty strings unexpected results

and has very loose precedence, so your last example is parsed as
(print "" =~ /.*/) and "" =~ /bar/

The first regex match succeeds (thus the 1), and the result of the second one is discarded. Use && instead of and to get the result you want.

See also: perlop.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2023-12-02 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (16 votes). Check out past polls.

    Notices?