in reply to ((Conditional, Ternary Operator)) Specifying default and non-default values
If you already have the very useful def in your toolbag:
then you can do this as:sub def { $_[0]= def($_[1],"") if ! defined $_[0]; return $_[0]; }
$ext{index} = 'pod'; for my $pod ( qw( HostCycle Instinet index ) ) { system "pod2html $pod" . def($ext{$pod},".pm") . " > $pod.html"; }
def (short for "define" which would be too easy to confuse with "defined") is useful for avoiding warnings. You can use it like || as above or like ||=. It differs from these two operators in that it triggers on definedness rather than truthness.
Note that def is so useful that even def uses it. ;)
- tye (but my friends call me "Tye")
|
|---|