The unsafe code is "unsafe.pl":sub peek_lexicals { my $h = peek_my(2); print "\nlexicals-----------------------\n"; print "keys=", join (", ", keys %$h), "-\n"; print "values=", join (", ", values %$h), "-\n"; print "end of lexicals-----------------------\n"; }
The checking code is "check_code.pl":my $b = 42; $c = "Hallo world\n"; print "printing lexical $b\n"; print "printing global $c\n";
When executed straight ("perl -d:Trace unsafe.pl") I get:use Safe; use Safe::Hole; my $SCRIPT_NAME = "unsafe.pl"; $QTL_HOLE_CPT = new Safe::Hole; $QTL_CPT = new Safe("QTL"); $Devel::Trace_shushu2::TRACE= 1; $QTL_CPT->rdo ( "$SCRIPT_NAME" );
When executed via the checker ("perl -d:Trace_shushu2 check_code.pl") I get:lexicals----------------------- keys=$b- values=SCALAR(0x810811c)- end of lexicals----------------------- lexicals----------------------- keys=$b- values=SCALAR(0x810811c)- end of lexicals----------------------- printing lexical 42 lexicals----------------------- keys=$b- values=SCALAR(0x810811c)- end of lexicals----------------------- printing global Hallo world
* I tried to play with the level given to the &peek_my, with no good effect.lexicals----------------------- keys=$SCRIPT_NAME- values=SCALAR(0x8108144)- end of lexicals----------------------- lexicals----------------------- keys=$SCRIPT_NAME- values=SCALAR(0x8108144)- end of lexicals----------------------- lexicals----------------------- keys=$SCRIPT_NAME- values=SCALAR(0x8108144)- end of lexicals----------------------- lexicals----------------------- keys=$default_share, $default_root, $VERSION- values=SCALAR(0x824f76c), SCALAR(0x810b704), SCALAR(0x8225304)- end of lexicals----------------------- lexicals----------------------- keys=$default_share, $default_root, $VERSION- values=SCALAR(0x824f76c), SCALAR(0x810b704), SCALAR(0x8225304)- end of lexicals----------------------- lexicals----------------------- keys=$default_share, $default_root, $VERSION- values=SCALAR(0x824f76c), SCALAR(0x810b704), SCALAR(0x8225304)- end of lexicals----------------------- printing lexical 42 lexicals----------------------- keys=$default_share, $default_root, $VERSION- values=SCALAR(0x824f76c), SCALAR(0x810b704), SCALAR(0x8225304)- end of lexicals----------------------- printing global Hallo world
In reply to PadWalker and Safe - getting the lexicals by shushu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |