ZlR has asked for the wisdom of the Perl Monks concerning the following question:
We have files that arrive in a directory and from the name of each file we extract a string $function . This is a function name defined in a module.
We then build a command with that $function and do an eval on it.
The reason we do this is because the files, functions, and modules holding them are defined by some other people so it's convenient for us : we just drop their modules in our lib directory and processing of new file types is automatic .
But we do this a lot of time (there are many files) and I've heard that eval is not good and not very performant.
Also this looks like the $$value problem, ie "i want to get a variable value from another variable" which, as i've seen here in the monastery, should be replaced by a hash solution .
Should we avoid the eval ?
Should we do &$function ? (no strict )
Should we do something else ?
Thanks for your advices !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling a sub from a variable ?
by Thilosophy (Curate) on Mar 22, 2005 at 09:57 UTC | |
by ZlR (Chaplain) on Mar 22, 2005 at 11:35 UTC | |
|
Re: Calling a sub from a variable ?
by Taulmarill (Deacon) on Mar 22, 2005 at 09:57 UTC | |
|
Re: Calling a sub from a variable ?
by Anonymous Monk on Mar 22, 2005 at 10:59 UTC | |
| |
|
Re: Calling a sub from a variable ?
by inq123 (Sexton) on Mar 22, 2005 at 10:26 UTC |