in reply to can't find mistake. lost in references
In your first version you use %_ to store data, which is a strange choice of variable. In the second version you use @_ to store your data which is very strange and - as you found out - has funny side effects. I have not really looked at your code but using $mat[$tc] instead of $_[$tc] everywhere should solve your problem.
UPDATE: In your subroutine
sub add{ my ($i, $j, $add) = @_; $_[$tc]{value}[$i][$j] += $add; }
you are even referring to two different @_ arrays explicitly. The one that passes the parameters into the subroutine and the global one that you use to store your data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: can't find mistake. lost in references (super global @_ is always in main @main::_ $main::_ )
by Anonymous Monk on Mar 14, 2015 at 18:16 UTC | |
by hdb (Monsignor) on Mar 14, 2015 at 18:25 UTC | |
by ikegami (Patriarch) on Mar 16, 2015 at 00:16 UTC | |
|
Re^2: can't find mistake. lost in references
by rsFalse (Chaplain) on Mar 14, 2015 at 17:59 UTC | |
by GotToBTru (Prior) on Mar 14, 2015 at 18:14 UTC | |
by Anonymous Monk on Mar 14, 2015 at 18:19 UTC | |
by hdb (Monsignor) on Mar 14, 2015 at 18:26 UTC |