Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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

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 meditating upon the Monastery: (5)
As of 2016-08-30 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (418 votes). Check out past polls.