Hi Ashley,

On Mon, May 31, 2004 at 10:04:33AM +1000, Ashley Maher wrote:
> sub insert_order_array {
> my    (
>       @new_value,
>       $new_value,
>       @current_array,
>       $current_array,
>       @ordered_array,
>       $i,
>       $j,
>       );
> 
> print "\nIn subroutine \n\n";
> 
>       @new_value = ();
>       @current_array = ();
>       @ordered_array = ();
> 
>       $new_value = $_[0];
> print "\nthe new array values\n";
> print $new_value->[0];
> print "\t";
> print $new_value->[1];
> print "\n";
> 
> #####
> print "\ncurrent array\n";
>       $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";
>    }
> }

Your problem is here, inside the subroutine - you're not passing an
array (@current_array), you're passing a reference to it, so there's
another layer of indirection required. So your print loop becomes:

  # 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 you'd return the array like:

  return @$current_array;


Does that help?

Cheers,
Gavin

-- 
Open Fusion P/L - Open Source Business Solutions [ Linux - Perl - Apache ]
ph:  02 9875 5032                        fax: 02 9875 4317
web: http://www.openfusion.com.au        mob: 0403 171712
- Fashion is a variable, but style is a constant - Programming Perl
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to