Hi perldigious,
... and then print the value of $max_rows one additional time.
ravi45722 is correct that the final print prints "0" - see my reply as to why.
use strict; use warnings; my $max_cols = 2; my $max_rows = 3; my $row_element = 0; foreach my $col_element (0 .. $max_cols) { foreach $row_element (0 .. $max_rows) { print "$row_element\n"; } } print "Last: $row_element\n"; __END__ 0 1 2 3 0 1 2 3 0 1 2 3 Last: 0
Regards,
-- Hauke D
In reply to Re^2: Variable in a foreach loop
by haukex
in thread Variable in a foreach loop
by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |