Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Reduce Redundant Repetition (Rus: use ternaries)

by Russ (Deacon)
on Jan 22, 2002 at 00:08 UTC ( #140477=note: print w/replies, xml ) Need Help??


in reply to Reduce Redundant Repetition

I don't see anyone using the ternary operator...
$targ = defined $opt_targ ? $opt_targ : 'localhost'; $firstport = defined $opt_firstport ? $opt_firstport : 1; $lastport = defined $opt_lastport ? $opt_lastport : 1024; $proto = defined $opt_proto ? $opt_proto : 'tcp'; $udptimeout = defined $opt_udptimeout ? $opt_udptimeout : 3; $contimeout = defined $opt_contimeout ? $opt_contimeout : 3; Usage('<lurch>You rang?</lurch>'), exit if defined $opt_help;
And it still works with valid zero values.

Russ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-05-16 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (63 votes). Check out past polls.

    Notices?