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

Re: Better way of matching

by kirbyk (Friar)
on Mar 08, 2006 at 19:14 UTC ( #535232=note: print w/ replies, xml ) Need Help??


in reply to Better way of matching

Another, more general case method, is to use the ? operator:

($net eq $x) ? 1 : 0; is the same as if ($net eq $x) { return 1; } else { return 0; }
The nice thing is that you can cascade them to make readable tableish structures:
($x eq $y) ? _do_something() : ($x eq $z) ? _do_something_else() : ($x eq $w) ? _do_a_third_thing() : _do_default_thing;

-- Kirby, WhitePages.com


Comment on Re: Better way of matching
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-11-23 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (131 votes), past polls