Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Passing regex result into function

by AnomalousMonk (Archbishop)
on Apr 16, 2016 at 00:24 UTC ( [id://1160595]=note: print w/replies, xml ) Need Help??


in reply to Re: Passing regex result into function
in thread Passing regex result into function

The  m// operator returns false (the empty string), not undef, on match failure when evaluated in scalar context:

c:\@Work\Perl\monks>perl -wMstrict -le "my $str = 'abc'; PassRegex(scalar($str =~ /x/i), 'parm2', 'parm3'); ;; use Data::Dumper; ;; sub PassRegex { print Dumper(\@_); print qq{BoolExpr = '$_[0]' parm2 = '$_[1]' parm3 = '$_[2]'}; return; } " $VAR1 = [ '', 'parm2', 'parm3' ]; BoolExpr = '' parm2 = 'parm2' parm3 = 'parm3'
Please see Regexp Quote-Like Operators.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found