Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: given-when with compiled regular expression returned from method confusing behavior

by JadeNB (Chaplain)
on Dec 12, 2009 at 22:42 UTC ( #812547=note: print w/replies, xml ) Need Help??


in reply to given-when with compiled regular expression returned from method confusing behavior

From Switch statements:

Most of the time, when(EXPR) is treated as an implicit smart match of $_, i.e. $_ ~~ EXPR. (See "Smart matching in detail" for more information on smart matching.) But when EXPR is one of the below exceptional cases, it is used directly as a boolean:
  • a subroutine or method call
Since $re->m1 is true, when ( $re->m1 ) succeeds.

UPDATE: I just noticed that the elided list is followed by

In those cases the value of EXPR is used directly as a boolean.
… in case you didn't believe it the first time, I guess. :-)

  • Comment on Re: given-when with compiled regular expression returned from method confusing behavior
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: given-when with compiled regular expression returned from method confusing behavior
by whakka (Hermit) on Dec 12, 2009 at 22:46 UTC
    Oh shoot somehow my eyes skipped over that part, thanks.

    Update: Harsh! The stress of hobby-coding when I have two finals next week are getting to me, I should really just do this when I have the time.

    Rejected witty excuses:

    • I guess you have to be smart to use smart-matching!
    • It seems the part where it says "These rules look complicated, but usually they will do what you want" doesn't really mean "...so go ahead and ignore the documentation."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2021-05-14 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?