Ashley Maher was once rumoured to have said:
> I've been banging my head for days over this. I'm trying to generate a
> 2D array in perl, pass this to a sub and do some work, and return it.
[SNIP]
> Anybody see what I'm stuffing, please?
[SNIP]
> @list_once = ( # multi dimentional array
> [ "3", "test1" ],
> [ "2", "test2" ],
> [ "7", "test3" ],
> [ "9", "test4" ],
> );
>
> # code ripped off from Programming Perl
> # print the whole thing one at a time
> print "\nIn main\n";
> for $i ( 0 .. $#list_once ) {
> for $j ( 0 .. $#{$list_once[$i]} ) {
> print "element $i $j is $list_once[$i][$j]\n";
its not $list_once[$i][$j], but rather $list_once[$i]->[$j]
@list_once contains references, so you use the ->[index] form to deference.
[SNIP]
> sub insert_order_array {
[SNIP]
> $current_array = $_[1];
>
> # print the whole thing one at a time
> for $i ( 0 .. $#current_array ) {
> for $j ( 0 .. $#{$current_array[$i]} ) {
> print "element $i $j is $current_array[$i][$j]\n";
and here, its $current_array->[$i]->[$j] ...
C.
--
--==============================================--
Crossfire | This email was brought to you
[EMAIL PROTECTED] | on 100% Recycled Electrons
--==============================================--
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html