Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 romping around the Monastery: (13)
As of 2014-12-29 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (192 votes), past polls