Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Subroutines within if statements

by lodin (Hermit)
on Feb 21, 2008 at 23:48 UTC ( [id://669425]=note: print w/replies, xml ) Need Help??


in reply to Re: Subroutines within if statements
in thread Subroutines within if statements

Nowadays you can use

use 5.010; if ("$answer" ~~ [ 'add', 'a' ]) { ... }
I explicitly stringify $answer because if $answer happens to be something else (like an object) the ~~ operator will act differently and I don't want that. On the contrary, I want to allow objects that may stringify to "add" or "a".

lodin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found