| | |
"use" statement inside an eval: problem?
![]() |
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:
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:
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.
perl Syntax (Toggle Plain Text)
$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)
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.
The one question you should not ask when teaching a new language structure is "Do you understand?". Do you understand?
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
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
Plato forgot the nullahedron..
![]() |
Similar Threads
- Javascript - Expected J and Expected Object errors (JavaScript / DHTML / AJAX)
- javascript works in IE but not working in firefox (JavaScript / DHTML / AJAX)
- problem with "for" statement (C++)
- Help using "include" inside of "echo" (PHP)
- Facing the problem on "RedirectFromLoginPage" (VB.NET)
- mysql_fetch_array problem (PHP)
- loop in main function to an "if" statement (C++)
Other Threads in the Perl Forum
- Previous Thread: Perl error reports: error prone
- Next Thread: perl JSP page calling from perl
| Thread Tools | Search this Thread |






