eval is a beautiful option is used correctly. Uses include:
- Checking for die conditions without die-ing
- Giving great user flexibility to specify options in config files. For example, I'm working with a program that has data files that are in essence miniature programs. The datafiles are loaded during run, and each mini-program will need to be executed many times. My solution? I translate the programs into perl when the file is loaded, and eval() them when I need to.
If you going to use eval with any user-specified data, it is a good idea to turn on taint-checking. See
perlman:perlrun for -T, and
perlman:perlsec for security concerns in perl.