Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Conditional, Ternary Operator - Specifying default and non-default values

by ncw (Friar)
on Oct 02, 2000 at 22:42 UTC ( #34951=note: print w/replies, xml ) Need Help??


in reply to ((Conditional, Ternary Operator)) Specifying default and non-default values

This script nicely demonstrates a bad use of map - if you are discarding the output of map then you should use for/foreach.

You can tidy the ternary operator up too. I'd write something like (untested but optimised for brevity :-)

$extension{index} = 'pod'; system "pod2html $_." . ($extension{$_} || 'pm') . " > $_.html" for (qw(HostCycle Instinet index));
For real I'd put an or die after the system though ;-)

Update: I did test it, and I got this result

$ perl -
[fx: cuts and pastes the code above]
Can't open HostCycle.pm: No such file or directory
Can't open Instinet.pm: No such file or directory
Can't open index.pod: No such file or directory
It works! (The error messages are from pod2html.)
  • Comment on Re: Conditional, Ternary Operator - Specifying default and non-default values
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-01-24 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (64 votes). Check out past polls.

    Notices?