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

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

Thread Previous | Thread Next
From:
Shlomi Fish
Date:
June 11, 2012 04:18
Subject:
Re: [PATCH] Add "use strict" to lib/perl5db.pl
Message ID:
20120611141247.3b2d6613@lap.shlomifish.org
Hi Dave,

On Mon, 11 Jun 2012 11:54:05 +0100
Dave Mitchell <davem@iabyn.com> 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 .

Thread Previous | Thread Next


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