Hi,
In the code below involving a loop, where is the "right" place to declare variable $var - inside or outside the loop?Thanks in advance :)foreach my $elem (@somearray) { my $var = $elem == 10 ? 'found 10' : 'other number'; } my $var; foreach my $elem (@somearray) { $var = $elem == 10 ? 'found 10' : 'other number'; }
In reply to Placement of "my" by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |