in reply to dynamic sub routine definitions?
Ah, a wheel waiting to be re-invented. ;-)
The do function will do exactly what you describe: read in a file, compile it as Perl, and execute it. It's been around a while, and there are many better alternatives, such as require and use. For more information on the latter two, look at perlmod.
However, being able to load and run a file will not make your program dynamic. You can't use stuff like this to replace an existing function definition, only to add a new one. What you want can be done, but requires more work: you need a level of indirection, so you can change the definition but keep the name. Possible, but difficult and very error-prone. Do you have a specific use in mind? (Other than "neat!" -- a valid reason, mind you.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: dynamic sub routine definitions?
by Eradicatore (Monk) on Jul 17, 2002 at 02:55 UTC | |
|
Re: Re: dynamic sub routine definitions?
by dragonchild (Archbishop) on Jul 17, 2002 at 16:04 UTC | |
by VSarkiss (Monsignor) on Jul 17, 2002 at 18:05 UTC |