in reply to Understanding use and require fully
use Module LIST is equivalent to:
So one _big_ difference is that use is executed at _compile_ time, whereas require is only executed at "run" time.BEGIN { require Module; import Module LIST; }
Generally I would always use use even if you don't export any symbols.
One place where require would be preferred over use is when you want to include a module only when it really is needed. So you'll see code like:
if ($type eq "Excel file") { require SpreadsheetReader::Excel; my $parser = SpreadsheetReader::Excel->new(); ... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Understanding use and require fully
by chromatic (Archbishop) on Aug 01, 2008 at 17:44 UTC |
In Section
Seekers of Perl Wisdom