Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: IF Statement Testing

by rg0now (Chaplain)
on May 14, 2005 at 09:27 UTC ( #457007=note: print w/ replies, xml ) Need Help??


in reply to Re: IF Statement Testing
in thread IF Statement Testing

But what I find more interesting is that the OP totally intuitively discovered junctions, and almost perfectly found the right syntax as well. Look at this variant:

if ($expire !~ any(1|2|3|4|5|6|7|8|9|10|11|12|13|14)){...}

Update: thanks gaal for lighting me up, although, I can not entirely grasp, what is the problem above...:-). Intuitively, $x ~~ none(...) should give the same result as $x !~ any(...), or at least, my intuition suggests this...

Anyway, here is an updated syntax that even more resembles to the OP's idea, and it actually works right in Pugs:

if (!($expire ~~ 1|2|3|4|5|6|7|8|9|10|11|12|13|14)) {...}
Interestingly, Pugs requires parens around the if condition. Is this a bug?


Comment on Re^2: IF Statement Testing
Select or Download Code
Re^3: IF Statement Testing
by gaal (Parson) on May 14, 2005 at 09:32 UTC
    That unfortunately doesn't work, because there always exists an element in the junction so that $expire !~ it. The condition is always true.
      Unfortunately, English usage of negatives doesn't map well to current Perl 6 syntax. I have started a discussion on perl6-language about whether we should do "not raising" or disallow use of negative ops on junctions entirely.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2015-07-03 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls