leocharre has asked for the wisdom of the Perl Monks concerning the following question:
I douse Cwd; sub iamin { return cwd; }
So I just require the modules I want if needed.sub iamin { require Cwd; return Cwd::cwd(); }
So, what if I am calling the sub or method a million times? Is perl just skipping over the require line because it's been already loaded? Or is there a little something going on that would eventually cause a performance hit?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is it ok to require a module in a sub or method?
by merlyn (Sage) on Sep 11, 2007 at 16:09 UTC | |
|
Re: Is it ok to require a module in a sub or method?
by ikegami (Patriarch) on Sep 11, 2007 at 16:30 UTC | |
|
Re: Is it ok to require a module in a sub or method?
by grinder (Bishop) on Sep 11, 2007 at 16:41 UTC | |
|
Re: Is it ok to require a module in a sub or method?
by almut (Canon) on Sep 11, 2007 at 17:55 UTC | |
|
Re: Is it ok to require a module in a sub or method?
by shmem (Chancellor) on Sep 11, 2007 at 21:54 UTC | |
|
Re: Is it ok to require a module in a sub or method?
by nothingmuch (Priest) on Sep 17, 2007 at 03:10 UTC |