develooper Front page | perl.perl5.porters | Postings from June 2012

Re: [PATCH] Add "use strict" to lib/perl5db.pl

Thread Previous
From:
Dave Mitchell
Date:
June 11, 2012 04:31
Subject:
Re: [PATCH] Add "use strict" to lib/perl5db.pl
Message ID:
20120611113112.GC2771@iabyn.com
On Mon, Jun 11, 2012 at 02:12:47PM +0300, Shlomi Fish wrote:
> > 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.

Ah sorry, didn't notice that!

-- 
Never do today what you can put off till tomorrow.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About