On Thu, Sep 04, 2003 at 01:32:57AM -0400, Guy Albertelli II wrote: > Dosen't seem to bleed default_root or default_share, and the bleed of > things other than expr is a perl 5.8.1 ism: > > Test script: > use strict; > use Safe; > print $]."\n"; > my $safe=new Safe; > > foreach my $name ('default_root','default_share','expr','obj','strict','root','evalcode','evalsub') { > print("Test $name is :".$safe->reval('return $'.$name.';').":\n"); > } > > > 5.008001 > Test default_root is :: > Test default_share is :: > Test expr is :return $expr;: > Test obj is :Safe=HASH(0x9f2bd28): > Test strict is :: > Test root is :Safe::Root0: > Test evalcode is :package Safe::Root0; sub { @_ = (); eval $expr; }: > Test evalsub is :CODE(0x9f45d0c): > > 5.008 > Test default_root is :: > Test default_share is :: > Test expr is :return $expr;: > Test obj is :: > Test strict is :: > Test root is :: > Test evalcode is :: > Test evalsub is :: > > 5.006001 > Test default_root is :: > Test default_share is :: > Test expr is :return $expr;: > Test obj is :: > Test strict is :: > Test root is :: > Test evalcode is :: > Test evalsub is :: This is because 5.8.1 includes fixes that allow nested evals to still see their full lexical scope. As of 5.8.1, to code to be eval'ed will be able to see: * any lexical vars declared above it but within reval(); * any lexical vars declared above reval(), but which are referred to within reval() - ie reval() acting as a closure. Currently there are no such variables. Any other lexicals will have gone out of scope by then, and any attempt to use them within an eval will give a '$foo is not available' warning. Having said that, I think Benjamin's suggestion of having an eval function at the very start of the script before any lexicals of any description have been declared, is a sensible idea. It will help protect us against any future changes to the code that inadvertently create a closure. Dave. -- "Foul and greedy Dwarf - you have eaten the last candle." - "Hoardes of the Things", BBC Radio.