4 ms·
Most Perl programmers think "it" when they use or see $_ Examples of using "it": map { (1/$_)+1 } 1..100; grep { $_ eq 'something' } @list; You can also
by draegtun 17y ago
Most Perl programmers think "it" when they use or see $_
Examples of using "it":
map { (1/$_)+1 } 1..100;
grep { $_ eq 'something' } @list;
You can also replicate the if and big_long_calculation using "for":
for (big_long_calculation) {
$_->foo;
}
But if u prefer to stick with "if" then you can do:
if (my $it = big_long_calculation) {
$it->foo;
}
And remember in a lot of cases using "it" isn't mandatory:
say for @list;
is same as:
say $_ for @list;