in reply to Re^5: How to speed up a nested loop?
in thread How to speed up a nested loop?
I may be wrong there, but the debugger seems to agree.
I don't see how the debugger can agree with that. Let's set up a multidimensional array and see what happens!
use Data::Dumper; my @multi; foreach my $i ( 10 .. 12 ) { foreach my $j ( 10 .. 12 ) { $multi[$i-10][$j-10] = "$i,$j"; } } my $what_is_this = $multi[1]; print Dumper $what_is_this; __END__ $VAR1 = [ '11,10', '11,11', '11,12' ];
The code in question actually gets a reference to an array, which is what's output by Data::Dumper.
To get the number you're talking about, the syntax would be:
my $n = scalar @{ $multi[1] };
The use of scalar is not needed functionally, but it makes it easier to see what's meant.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: How to speed up a nested loop?
by Xenofur (Monk) on Sep 18, 2008 at 16:52 UTC | |
by tilly (Archbishop) on Sep 18, 2008 at 23:04 UTC | |
by Xenofur (Monk) on Sep 19, 2008 at 09:42 UTC | |
by tilly (Archbishop) on Sep 19, 2008 at 18:51 UTC | |
by Xenofur (Monk) on Sep 21, 2008 at 09:39 UTC | |
|