How does the function loading works in Perl
--000325556a0a5bba2b049d866b23
Content-Type: text/plain; charset=UTF-8
Hi,
I have this basic question from a long time now, so thought of asking.
A Perl script may have many functions. When we execute the script via Perl
Interpreter, does all the functions are loaded into memory?
Sometimes we just like to keep the coded functions in the script with the
idea that we may need them in future. Will removing an un-called functions
improve the execution time?
~Parag
--000325556a0a5bba2b049d866b23--
Re: How does the function loading works in Perl
2011/3/3 Parag Kalra <paragkalra [at] gmail.com>:
> Hi,
>
> I have this basic question from a long time now, so thought of asking.
>
> A Perl script may have many functions. When we execute the script via Perl
> Interpreter, does all the functions are loaded into memory?
>
Though there is a stuff called "AUTOLOAD", but I think all the
functions have been loaded into the memory once the script is run.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: How does the function loading works in Perl
On 11-03-02 04:15 PM, Parag Kalra wrote:
> A Perl script may have many functions. When we execute the script via Perl
> Interpreter, does all the functions are loaded into memory?
>
All the functions are compiled and loaded.
> Sometimes we just like to keep the coded functions in the script with the
> idea that we may need them in future. Will removing an un-called functions
> improve the execution time?
Yes but on modern machines, you will need an awful lot of subs to get a
noticeable slow down.
The AUTOLOAD feature can be used to delay the compilation and loading of
a sub but I have never seen it used in practice. Most modern machines
are fast enough so compiling unused subs is not a problem.
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: How does the function loading works in Perl
On Wed, 02 Mar 2011 17:02:30 -0500, Shawn H Corey wrote:
> On 11-03-02 04:15 PM, Parag Kalra wrote:
>> A Perl script may have many functions. When we execute the script via
>> Perl Interpreter, does all the functions are loaded into memory?
>>
>>
> All the functions are compiled and loaded.
>
>> Sometimes we just like to keep the coded functions in the script with
>> the idea that we may need them in future. Will removing an un-called
>> functions improve the execution time?
>
> Yes but on modern machines, you will need an awful lot of subs to get a
> noticeable slow down.
Right.
> The AUTOLOAD feature can be used to delay the compilation and loading of
> a sub
I think you mean AutoLoader. Or SelfLoader. They may use AUTOLOAD under
the hood but that's not the direction to point the user in.
> but I have never seen it used in practice.
There are a fair number of modules on CPAN using it. And in the core:
POSIX, for instance.
--
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl3/
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/