in reply to eval question
Be aware that most Perl experts discourage the use of string eval. For example:
- merlyn in •Re^2: Dynamically constructed function calls states: Do not resort to eval-string if other means are available. You're firing up the compiler (slower than almost any other solution), and exposing yourself to hard to debug and hard to secure practices.
- In this quiz of the week MJD states: A good rule of thumb is that unless what you're trying to do is most clearly described as "compile and run arbitrary Perl code", it's probably a mistake to use 'eval' to do it.
- Perl Best Practices, Chapter 8, has a guideline titled: Avoid string eval. Conway argues that string eval can be slow; produces run time warnings rather than more desirable compile time warnings; and code that generates other code tends to be harder to maintain.
Update: for more background on this topic see:
- The safety of string eval and block eval.
- Re^3: Create sort function from a text file (string eval vs block eval)
- Undumping Perl by haukex
See also: Re: eval to replace die? (Exceptions and Error Handling References)
|
---|
In Section
Seekers of Perl Wisdom