Your code becomes:# Localize expression into $_ using a single-value 'for'. # $_ is default for many Perl functions. for ($some_very_long_expression_you_will_use_more_than_once) { die unless defined; die unless /^expected/; do_something($_); do_something_else($_); }
for ( $hash1->{'a'}->{'b'}->{'c'} ) { $hash2->{'bob'} = $_ if defined; }
In reply to Idiom: Localize with 'for'
by Util
in thread re-using a hash reference (was: Mar)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |