--- John <[EMAIL PROTECTED]> wrote:
> If you put them in a module are they parsed before they are called?
> Does it matter whether you use "use" or "require"? When is it better
> to specify subroutines when you use "use"?
See perldoc -f use and perldoc -f require.
"use" happens at compile time. When a module is "use"d, it's pretty much equivalent
to the
following:
BEGIN
{
require Foo;
import FOO qw/ bar baz /;
}
If you simply "require" a module, this will occur at runtime, but the module won't be
used if the
require isn't called. This is useful in functions or methods that are called
infrequently:
use strict;
use warnings;
error_handling( "You fool!\n", { foo => 3 } );
sub error_handling
{
my ( $message, $data ) = @_;
require Data::Dumper;
Data::Dumper->import;
die $message, Dumper( $data );
}
(That's just an example, not really a proper error handling routine)
Now, if we have a program that rarely, if ever, calls the error_handling() routine, we
don't incur
the overhead of compiling Data::Dumper unless we actually need it.
Cheers,
Curtis "Ovid" Poe
=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]