in reply to Loading a function from another file dynamically?!

If I understand the question correctly, you'd like to be able to run sub A in file A from file B. To do this, you can use Exporter:

File A

package PackageName; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(moo); # Put function names, seperated by + spaces, # that you want to be able to use sub moo { # do stuff }

File B

use PackageName; moo();

Basically, you're creating a simple module. You'd also be able to accomplish what you want it via eval, but modules are cleaner.

Replies are listed 'Best First'.
Re: Re: Loading a function from another file dynamically?!
by Anonymous Monk on Mar 23, 2003 at 18:53 UTC
    not exactly. I wrote a parser that parses SSI -like tags and would like to able to specify:
    A) the source file to load
    B) the name of the sub to run
    C) the args used
    
    and now I am trying to figure out the code for running the function in the file specified etc. I guess it has something to do with evals and packages... but I know too little Perl for figuring it out, and no manual has anything on this.

    Edit by tye, remove PRE tags around long lines