http://qs321.pair.com?node_id=245305


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

thanks. that worked well :).. I think I'll just use number 3 since it's the shortest. eval() return values aren't that important to me, since it's only for my wwwsite. There aren't any real differences between these methods, are there?
  • Comment on Re: Re: Loading a function from another file dynamically?!

Replies are listed 'Best First'.
Re: Re: Re: Loading a function from another file dynamically?!
by dakkar (Hermit) on Mar 23, 2003 at 19:26 UTC

    The first method loads the file into a string, then evals it.

    The second method uses an external program (cat) to read the file, taking up a bit more resources.

    The third method is the "preferred" way of doing it, but has a couple of differences: the file is looked for in all the directories listed in the @INC array; the code in the file will not be able to access lexical variables declared (with my) in the scope in which the do is executed. (for details, perldoc -f do).

    -- 
            dakkar - Mobilis in mobile