[Phoenix-pm] perl eval and the No Execute chips

Metz, Bobby W, WWCS bwmetz at att.com
Thu Sep 14 09:47:27 PDT 2006


	Using eval to load static hashes...interesting, never done that
before.  It would be interesting to compare the load speed of that
method vs. the others.  I know in my own testing I've found that writing
a sub to handle hash population from a data file runs faster and takes
up less memory than when using a pre-built hash syntax using "use" or
"require".  Granted the hashes were fairly simple ones but does that
really matter?  Anyone else ever noticed similar speed/memory results?

Bobby

-----Original Message-----
From: phoenix-pm-bounces+bwmetz=att.com at pm.org
[mailto:phoenix-pm-bounces+bwmetz=att.com at pm.org]
Sent: Wednesday, September 13, 2006 6:28 PM
To: Jerry Davis
Cc: phoenix-pm at pm.org
Subject: Re: [Phoenix-pm] perl eval and the No Execute chips


Maybe 99% was a bit dramatic.  As long as you're setting up the config
files
and bad people don't have write access to them, you're fine, and that's
a legit use of eval.  Usually I 'require' or 'use' files like that (and
put a 
1; on the end of them) rather than 'eval', but there isn't *that* much 
difference (the perldoc for require and use point out the other little
helpful
things they do).  And of course bad people shouldn't be able to specify
which file 
gets used as the config file without serious restriction on their
choice.

-scott

On  0, Jerry Davis <jdawgaz at cox.net> wrote:
> On Wed, 13 Sep 2006 17:37:06 +0000
> Scott Walters <scott@> wrote:
> 
> > Stops executing, starts parsing/compiling again, and then executes
the
> > result of that again.  I've said it before and I'll say it again...
> > 95% of the time people eval, they really want a closure instead.
> 
> the reason I asked, is that I do make use of eval, and in what I think
> is a legal way.
> 
> what I normally do in an eval, is on the command line I pass the name
> of a file which is really a short perl script which is really a hash
> full of static data.
> 
> sort of like:
> 
> our %h;
> 
> $h{somekey}{somesubkey} = value;
> ...
> 
> I then eval this file, which sets sets up my all my data, and I just
> use that data in the program.
> 
> Different files hold exactly the same hash but with different values.
> 
> This has worked really really well for me, and I was just a little
> alarmed over what I saw on /.
> 
> Jerry
> 
> 
> 
> > 
> > -scott
> > 
> > On  0, Andrew Johnson <andypm at exiledplanet.org> wrote:
> > > 
> > >    On 9/12/06, Brock <[1]awwaiid at thelackthereof.org> wrote:
> > >    
> > >    <snip>
> > >    
> > >    
> > >      But that's a bit of a side track. Really, let's expand the
> > > question to
> > >      this -- How does "eval" work?
> > >      
> > >    That's easy:  it's MAGIC!!  :-)
> > >    [aj]
> > > 
> > > References
> > > 
> > >    1. mailto:awwaiid at thelackthereof.org
> > 
> > > _______________________________________________
> > > Phoenix-pm mailing list
> > > Phoenix-pm at pm.org
> > > http://mail.pm.org/mailman/listinfo/phoenix-pm
> > _______________________________________________
> > Phoenix-pm mailing list
> > Phoenix-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/phoenix-pm
> 
> 
> -- 
> Happy Trails!
>  
> Hobbit Name: Pimpernel Loamsdown
> Registered Linux User: 275424
>  
> Jeep Motto #2: Paved Roads are a Fine Example of Needless Government
> Spending!
> _______________________________________________
> Phoenix-pm mailing list
> Phoenix-pm at pm.org
> http://mail.pm.org/mailman/listinfo/phoenix-pm
_______________________________________________
Phoenix-pm mailing list
Phoenix-pm at pm.org
http://mail.pm.org/mailman/listinfo/phoenix-pm


More information about the Phoenix-pm mailing list