3 ms·
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 cou
by draegtun 13y ago
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);
}