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