
shlomif at shlomifish
Jun 11, 2012, 4:12 AM
Post #3 of 9
(122 views)
Permalink
|
|
Re: [PATCH] Add "use strict" to lib/perl5db.pl
[In reply to]
|
|
Hi Dave, On Mon, 11 Jun 2012 11:54:05 +0100 Dave Mitchell <davem [at] iabyn> wrote: > On Mon, Jun 11, 2012 at 12:43:47PM +0300, Shlomi Fish wrote: > > the attached patch against blead adds "use strict" to lib/perl5db.pl, which is > > the default perl debugger (what gets invoked by writing "perl -d". > > > @@ -510,6 +510,8 @@ where it has to go. > > > > package DB; > > > > +use strict; > > + > > BEGIN {eval 'use IO::Handle'}; # Needed for flush only? breaks under miniperl > > This causes 'use strict' to be in scope for the 'eval' sub, which means > that code evaluated with 'x' is now run under 'use strict'. > Well, inside "sub eval" I am calling «eval ""» like that: @res = eval "$usercontext $evalarg;\n"; # '\n' for nice recursive debug In turn, $usercontext is calculated by sub _calc_usercontext { my ($package) = @_; # Cancel strict completely for the evaluated code, so the code # the user evaluates won't be affected by it. (Shlomi Fish) return 'no strict; ($@, $!, $^E, $,, $/, $\, $^W) = @saved;' . "package $package;"; # this won't let them modify, alas } And as one can see, "no strict;" is added there, so it should not affect the evaled code. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "Humanity" - Parody of Modern Life - http://shlom.in/humanity My opinions may seem crazy but they all make sense. Insane sense, but sense nonetheless. Please reply to list if it's a mailing list post - http://shlom.in/reply .
|