in reply to re-using a hash reference (was: Mar)
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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Idiom: Localize with 'for'
by tadman (Prior) on Jun 09, 2002 at 05:36 UTC |