in reply to Re: Where is my foreach data going to?
in thread Where is my foreach data going to?
You will get -use strict; use Data::Dumper; my @array; for (my $i=0;$i<2;$i++) { for (my $j=0;$j<2;$j++) { @array[$i, $j] = "$i.$j"; } } print "Case 1...\n"; print Dumper(@array); for (my $i=0;$i<2;$i++) { for (my $j=0;$j<2;$j++) { $array[$i][$j] = "$i . $j"; } } print "Case 2...\n"; print Dumper(@array); for (my $i=0;$i<2;$i++) { for (my $j=0;$j<2;$j++) { $array[$i, $j] = "$i . $j"; } } print "Case 3...\n"; print Dumper(@array);
As you can see, only case 2 gives you what you want, a two dimensional array.Case 1... $VAR1 = undef; $VAR2 = undef; Case 2... $VAR1 = [ '0 . 0', '0 . 1' ]; $VAR2 = [ '1 . 0', '1 . 1' ]; Case 3... $VAR1 = '1 . 0'; $VAR2 = '1 . 1';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Where is my foreach data going to?
by leriksen (Curate) on Sep 18, 2003 at 06:37 UTC | |
by demerphq (Chancellor) on Sep 18, 2003 at 11:34 UTC |