Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://438256]
help
Chatterbox?
[thezip]: oops... My mind is backwards (this works): find . -mindepth 2 -name "*.csv" | xargs wc -l

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2016-12-06 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (113 votes). Check out past polls.