On 5/13/09 Wed May 13, 2009 4:48 PM, "Steve Bertrand" <st...@ibctech.ca> scribbled:
> Hi all, > > I'm trying to push a scalar onto an array. The array I'm trying to > push() to is the first element of another array. I can't figure out what > I'm missing. It would be appreciated if someone could point me in the > right direction. > > if (-e $data_file) { > > $graph_data = retrieve $data_file; > > $x_axis = $graph_data->[0][0]; > $x_axis++; > > # start pushing the next days data into the aoa > push ($graph_data->[0], ($x_axis)); > > store $graph_data, $data_file; > } Your program shouldn't even compile. I get: "Type of arg 1 to push must be array (not array element) at ..." The first argument of push should be an array, not a scalar (even if that scalar is a reference to an array). push( @{$graph_data->[0]}, $x_axis ); (the parentheses around $x_axis are unnecessary.) If you are having more trouble, use the Data::Dumper module to inspect the contents of your AoA: use Data::Dumper; print Dumper(\$graph_data); -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/