in reply to Referencing/returning array of hashes from sub
my (@date, @F_SCORE, @F_SCORE_BOX,This assignment makes @date gobble up all the values on the RHS, leaving the other arrays empty. A smaller example will illustrate this:
use warnings; use strict; use Data::Dumper; my ($date_ref) = [0..3]; my ($F_SCORE_ref) = [5..7]; my (@date, @F_SCORE) = (@$date_ref, @$F_SCORE_ref); print Dumper(\@date); print Dumper(\@F_SCORE); __END__ $VAR1 = [ 0, 1, 2, 3, 5, 6, 7 ]; $VAR1 = [];
From perldata:
You can actually put an array or hash anywhere in the list, but the first one in the list will soak up all the values, and anything after it will become undefined.You should consider a different data structure: perldsc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Referencing/returning array of hashes from sub
by PoGGiE (Initiate) on Jun 08, 2011 at 18:23 UTC | |
by chromatic (Archbishop) on Jun 08, 2011 at 18:36 UTC | |
by PoGGiE (Initiate) on Jun 08, 2011 at 20:26 UTC | |
by chromatic (Archbishop) on Jun 08, 2011 at 21:23 UTC | |
by planetscape (Chancellor) on Jun 09, 2011 at 03:57 UTC |