in reply to The correct way to return arrays from a module

I hope you are aware that this code new Itiv::Hw->all_hw($dbh, $filter); calls new() on whatever Itv::Hw->all(..) returns. Looking at the code this will not work, ever.

Also, you cannot return arrays from functions (only lists), but you can return array references as you do here. Array references are not automatically converted to arrays, however, and because assigning to an array is "greedy" the first array in the left hand side of the assingment is going to recieve all the values (which are in this case, the two array references).

You probably want

my $object = Itiv::Hw->new(); my ($cols, $hw) = $object->all_hw($dbh, $filter); # and then... foreach (@$cols) { .... }

Replies are listed 'Best First'.
Re^2: The correct way to return arrays from a module
by neilwatson (Priest) on Aug 07, 2004 at 15:06 UTC