Generally if you do something like that you need to pass the parent's variables into the child sub. If the parent sub needs to see changes in the variables then you need to pass references to the variables into the child sub. At that point all the references to the pass by reference variables in the child sub need to be adjusted. Consider:
sub parent { my $valueOnly; my $needsUpdates; child ($valueOnly, \$needsUpdates); } sub child { my ($valueOnly, $needsUpdates) = @_; $$needsUpdate = $valueOnly; # was: $needsUpdate = $valueOnly; }
Notice the second $ prepended to $needsUpdate to dereference it in the child sub.
In reply to Re: Can a large subroutine be split in two (e.g. parent and child relationship)?
by GrandFather
in thread Can a large subroutine be split in two (e.g. parent and child relationship)?
by newbie00
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |