Next Making Programs Faster 93

Getting the Wrong Answer as Quickly as Possible

      Message-ID: <3A317EF2.3000509@klamath.dyndns.org>
      Subject: eval() performance
      Date: Sat, 09 Dec 2000 00:38:11 GMT
      I've been taking a look at some old Perl code, written by
      someone else.  The main part of the app does the following
      (it's a CGI script):
      1 Read in a certain CGI parameter
      2 Based on this parameter, open() a certain Perl script as a
      text file and read the contents into a single scalar variable
      3 Use the following code to evaluate the loaded code:
      eval $code;
      if ($@) {
           #handle errors
      }
      My question is: how would you improve this? My first
      thought was to use an eval block - i.e.
      eval {$code;};
      if ($@) {
           #handle errors
      }
      Would this improve performance? 

Next Copyright © 2003 M. J. Dominus