----- Original Message ---- > From: Michael G Schwern <schw...@pobox.com> > > >> %$Test = %$child; > >> > >> Watch out for edge cases of when subtest() dies, make sure the > >> parent's guts > >> get put back. > > > > "local" should be good for doing that right? > > Normally, yes. local $Test will localize the value of $Test, which is a > reference, not its guts. local %$Test would seem to be the right thing, but > I'm not sure if that will DWIM.
I've generally been extremely pleased with how robust 'local $hash->{value}' is, but you can't localize lexical variables. I'd have to do something like: my $test = Test::Builder->new; local $test->{$_} = $child->{$_} for keys %$child; (And you have to write it similar to that to avoid scoping issues). I think that's safe, but would a clone be safer? We have file handles stored in $test and I'm unsure of the behavior there or how to safely test that. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog - http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6