943,964 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 4754
  • Perl RSS
Jan 27th, 2007
0

"use" statement inside an eval: problem?

Expand Post »
Hello everyone. Is it allowed to have a "use" statement inside an eval that is compiled separately to the enclosing program (i.e. eval EXPR, not eval BLOCK). The reason I want to do this is, I have modules of code that I don't want to be compiled every time my script is run as they will not be needed very often. One of them contains Digest::MD5 which is quite bulky. I tried running these modules as child processes with:

perl Syntax (Toggle Plain Text)
  1. $pwd_hash = `perl password_md5.pl $field[1]`;

This worked on my test server, but not on my host server which doesn't seem to allow this kind of behaviour. I'm looking into that issue. I came up with the solution of loading the modules from a file at runtime and passing the code to an eval EXPR. This works with one of them and should be more efficient as it avoids the overhead incurred from starting a new process or thread. The other module includes:

perl Syntax (Toggle Plain Text)
  1. use Digest::MD5;

and this seems to be causing a problem. Is it possible to use "use" inside an eval like this, or will I have to include the MD5 :: Digest code manually? Any advice appriciated.

Steven.
Last edited by Mushy-pea; Jan 27th, 2007 at 5:07 pm.
Similar Threads
Reputation Points: 47
Solved Threads: 1
Posting Whiz in Training
Mushy-pea is offline Offline
271 posts
since Jun 2006
Jan 28th, 2007
0

Re: "use" statement inside an eval: problem?

I had a similar intention, and hit exactly the same problem (worked offline but not online); here's what I did:

http://www.daniweb.com/techtalkforums/thread63673.html

That relies on you being able to instantiate an object from the 'use' and return it from the eval... If the module that you use is non OO, perhaps you'll have a problem doing that O_o
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Perl error reports: error prone
Next Thread in Perl Forum Timeline: perl JSP page calling from perl





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC