use strict; use warnings; my $row_element = 0; my $col_element = 0; foreach my $col_element (0 .. $max_cols) { foreach $row_element (0 .. $max_rows) { print $row_element; } } print $row_element;
Here in the foreach loop I am changing the value of $row_element. Still its printing zero out of the loop. Why??? I am maintaining scope by initialising at top.
In reply to Variable in a foreach loop by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |