in reply to Re: passing array references
in thread passing array references
But leading back to your original question, my initial thoughts would also be to use a hash_ref. Your scalar-array data pattern lends itself well to a hash. And if the hash key (scalar) is a key to a particular function that you wish to perform on the array then your method becomes easily scalable.sub get_my_list { my $array_ref = $_; if( &some_other_func() ){ @{$array_ref} = qw( Yadda yAdda yaDda ); return 1; } return 0; } if( get_my_list(\@array) ){ print 'I got this array: '.join(',',@array); }else{ print 'Failed'; }
|
|---|