Re:Avoid Null Checks by Replacing Finders with Tellers
by draegtun on Tuesday June 18, 2013 @04:53AM
(#5898227)
re: Perl - You're probably thinking of $_, which most Perl programmers call it.
However this only gets topicalised in bare for & while but not if.
So you could do...
for (something_exists) {
do_something_to($_);
}
... as long as something_exists doesn't return a list :)More common approach I've seen in Perl (and other languages where variable declarations return its value) is this:
if (my $it = something_exists) {
do_something_to($it);
}
I believe Perl has something similar but it was less readable.