> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 13, 2001 3:05 PM
> To: [EMAIL PROTECTED]
> Subject: eval
> 
> 
> A rather stupid question but I would appreciate a good answer........

It's a good question, but have you read perldoc -f eval?

> 
> What is the point of the eval function. What would be a 
> reason to use it.
> From what I gather it is a function that evaluates a piece of 
> Perl code and
> returns the exit status of the code.
> 
> What is the point. Why no just write code and check for exit status of
> commands where such a check is necessary.........

There are two forms of eval. The string form is used to compile code
"on the fly", which makes perl into a truly dynamic language.

The block form is used for error trapping, since not all functions
return an error value. Some call die() instead. Wrapping that code
inside an eval {} block let's you catch the error instead of having
your script die.

> 
> Could it have something to do with run-time code 
> generation............. ??

Yes, the string form of eval does.

Both forms are used extensively.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to