SPUG: Problem deleting files, last one

Daniel Chetlin daniel at chetlin.com
Mon Dec 4 01:51:22 CST 2000

On Fri, Dec 01, 2000 at 11:10:20AM -0800, Brittingham, John wrote:
> 		my @filenames = eval "<$oldfile>";

I hate to keep beating a dead horse, but since you said this is the
solution you actually chose, I thought I'd try once more.

This is really not the correct way to do things. The problem you were
facing was the fact that `<$oldfile>' was being interpreted as a
readline instead of a glob. There are easier, faster, and more secure
ways of solving that then using `eval STRING'.  For example:

  * my @filenames = glob($oldfile);
  * my @filenames = <${oldfile}>

In this specific instance, you have control over the `$oldfile'
variable. But code changes. Consider what would happen if `$oldfile'
contained ">;system('rm -rf /')". Etc. `eval STRING' is something to
always be very careful of. It can be quite useful, but there's no reason
to use it here.


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list