Subject: | Sub::Quote doesn't close over its captured variables |
It makes a shallow copy of them instead. The attached test case illustrates the issue.
It's possible that the current behaviour is intentional, but if so I think it really needs to be documented.
Subject: | sub-quote-closures.t |
use strict;
use warnings;
use Test::More;
use Sub::Quote;
my $sound = 0;
quote_sub 'Silly::dagron',
q{ return(++$sound % 2 ? 'burninate' : 'roar') },
{ '$sound' => \$sound };
is(Silly::dagron(), 'burninate');
is(Silly::dagron(), 'roar');
is(Silly::dagron(), 'burninate');
is(Silly::dagron(), 'roar');
is($sound, 4, '$sound successfully closed over');
done_testing;