in reply to shift and logical or
Consider
my $val ||= "undefined"
Which is equivalent to:
if (!$val) { $val = "undefined"; }
Blocks of code like that tend to clutter up your code.
Also consider:
$val = ($val) ? "defined" : "undefined";
Which is equivalent to:
if ($val) { $val = "defined"; } else { $val = "undefined"; }
Also, remember perl evaluates expressions for truth.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: shift and logical or
by Kenosis (Priest) on Nov 17, 2012 at 02:41 UTC |
In Section
Seekers of Perl Wisdom