I cannot decide which approach is more (1) idiomatic Perl, (2) efficient, or (3) "clear".
Let me explain by code. First, I can do
sub something {
...
$ref->{size} = 10;
$ref->{name} = "Foo";
$ref->{volume} = 100;
push (@references, $ref);
...
return @references;
}
or, I can do
sub something {
...
push (@names, "Foo");
$sizes{Foo} = 10;
$volumes{Foo} = 100;
...
return (\@names, \%sizes, \%volumes);
}
Both do essentially the same thing. The important thing is, I need the array, because I need to keep the order.
I know, there is always more than one way to do something, but still, which one of these two would you prefer?