![]() |
|
There's more than one way to do things | |
PerlMonks |
Re: Help understanding a single line of perl: my $count = $row[0] ? $row[0] : 0;by ramlight (Friar) |
on Aug 21, 2009 at 18:54 UTC ( #790438=note: print w/replies, xml ) | Need Help?? |
One question that might occur to someone who is new to this construct is "Why use it in this case?"
Because an undefined value is false, this little snippet of code will make sure that count is always defined to a specific value, even if $row[0] is not defined. So if your @row was the result of some operation that happened to return an empty list, $count would set to 0 rather than '';
In Section
Seekers of Perl Wisdom
|
|