Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^3: Why does this sub grab the whole hashby davido (Cardinal) |
on Nov 11, 2011 at 18:06 UTC ( [id://937645]=note: print w/replies, xml ) | Need Help?? |
@dr is not lexically scoped. The result is that each time the sub is called, unless you're reinitializing it somewhere that we're not seeing, @dr still has cruft in it from previous calls to the subroutine. It probably needs to be declared as my @dr. $done is also not lexically scoped, but that's not as important as you're doing an assignment to it rather than an append. push is like an append for an array. If the array already has junk in it, you're just adding to what's already there. Dave
In Section
Seekers of Perl Wisdom
|
|