# New Ticket Created by Steve Schulze # Please include the string: [perl #129344] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=129344 >
I have a subroutine that may recurse, that contains a "my" counter variable. Each recursion gets its own copy of the variable, but it seems that when the "inner" recursion returns, the "outer" version of the variable gets the contents from the "inner" routine. See cut down snippet: <perl6> sub process-list (@items, $level = 0) { my $count = 1; # leaks on recursion? multi sub process-item ($item, $level) { ' ' x $level ~ $count++ ~ ') ' ~ $item } multi sub process-item (@array, $level) { process-list(@array, $level + 1) } join "\n", map { process-item($_, $level) }, @items; } my @a = 'a', 'b'; put process-list([ 9, @a, 7, 6, @a, 15, 11 ]); </perl6> Output: Got 1) 9 1) a 2) b 3) 7 4) 6 1) a 2) b 3) 15 4) 11 Expected: 1) 9 1) a 2) b 2) 7 3) 6 1) a 2) b 4) 15 5) 11