in reply to Re^3: undefined value in array reference
in thread undefined value in array reference
Well, in this particular set of data, $x maxes out at 500 and $y maxes out at 10,000. So yes, it's an indexing issue related to @{$aob[ $y - 1 ]} but nothing I've read points to a simple one-line solution that actually produces the proper output.
As is my usual, my current solution is a little sideways. In the section above calling popnum3:
thenforeach my $r (0 .. $total){ $row[$r] = $aob[$r][$y - 1]; } my @rowin = grep { $_ ne q{} } @row; $mean = mean(@rowin);
sub popnum3 { my ( $x, $y, $z, $mean ) = @_; $aob[$x][$y] = $mean * ( 1 + $z ); return $aob[$x][$y]; }
Supposedly @row = @{$aob[ $y - 1 ]} should be equivalent to
But it didn't work out that way.foreach my $r (0 .. $total){ $row[$r] = $aob[$r][$y - 1]; }
BTW, the grep is in there since I know that although the current parameters shouldn't produce any blanks in the output, other parameters will.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: undefined value in array reference
by kennethk (Abbot) on Mar 31, 2011 at 21:56 UTC | |
by Dandello (Monk) on Mar 31, 2011 at 22:22 UTC | |
by kennethk (Abbot) on Mar 31, 2011 at 22:32 UTC |
In Section
Seekers of Perl Wisdom