Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Trap in Test::Unit::Assert? Avoidance

by Jasper (Chaplain)
on Mar 10, 2005 at 14:21 UTC ( #438256=note: print w/ replies, xml ) Need Help??


in reply to Re: Trap in Test::Unit::Assert? Avoidance
in thread Trap in Test::Unit::Assert? Avoidance

Yes, absolutely right. My mistake was that I thought a straight match returned a scalar value unless it had //g, or matching parens in the regexp. Live and learn, I suppose.


Comment on Re^2: Trap in Test::Unit::Assert? Avoidance
Re^3: Trap in Test::Unit::Assert? Avoidance
by Anonymous Monk on Mar 10, 2005 at 15:21 UTC
    Nothing returns a scalar in list context. If it's in list context, it will return a list. Even if it's a single element list. ;-)

    Note that a failing regex in list context returning anything but an empty list would be very inconvenient, as this code is common:

    if (my @matches = $var =~ /PATTERN/) { # match } else { # did not match }
    If the failing match would return undef, 0, or the empty string, the result of the assignment becomes true (because a list assignment in scalar context returns the number of things on the RHS of the assignment).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-08-02 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls