Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

problem with eval

by Anonymous Monk
on Feb 23, 2001 at 18:32 UTC ( [id://60483]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to read a file containing perl program in another perl program and evaluate it in the second program's context. I wrap the read text in a package before invoking eval. The problem is that it works for small files, but for a bigger file, it says "panic: top_env". please help. thanks, jay

Replies are listed 'Best First'.
Re (tilly) 1: problem with eval
by tilly (Archbishop) on Feb 23, 2001 at 21:16 UTC
    Congratulations, you found a bug in your version of Perl!

    Here is how to tell. Try typing:

    perldoc perldiag
    and then to find your message do:
    /panic: top
    This will give you the following text:
    panic: top_env (P) The compiler attempted to do a goto, or something weird like that.
    The description at the top of perldiag says that (P) indicates a trappable internal error that should never arise.

    Now if you can narrow down what size it starts running into trouble with, I would suggest using the handy perlbug utility and reporting this as a bug. You probably should not send the offending file (you say it is large) but be willing to send it privately on request.

    Other posters are correct in saying that for your problem it is probably better to use a module, do, require, etc rather than an explicit eval. However there are times when an eval is right even so, and it shouldn't randomly break.

    Important Note
    If you see an explicit error message like this, don't guess. Go straight to the documentation and look for the description of what that message means. If there are a stream of messages, the first one is probably the real error and the rest are consequences, so look up the first one and try to fix that. This advice is good whether you get the message, a co-worker, or it is a random question.

Re: problem with eval
by jeroenes (Priest) on Feb 23, 2001 at 18:45 UTC
    You are probably better of using do or require, or even by writing a module, see perlmod.

    Hope this helps,

    Jeroen
    "We are not alone"(FZ)

Re: problem with eval
by Jouke (Curate) on Feb 23, 2001 at 18:39 UTC
    Could you post some code which causes this? The script evaluating the other files and a file that causes the error ?

    Jouke Visser, Perl 'Adept'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://60483]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found