Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://438256]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-05-25 06:07 GMT
Find Nodes?
    Voting Booth?