[EMAIL PROTECTED] wrote:
Hi,

I have to write several perl scripts with a number of modules included.
Therefore, I have to type many "use" statements at the top of each script. Is
there a way to dump all these "use" statements in a different file and then just
include that file everytime I have to include these "use" statements?

I know that writing a module is a great way to do something like that, but
doesn't a module export variables and subroutines? How can I make a module
export "use" statements?

Perl has three distinct ways of separating content: modules, packages, and objects. Modules do not export variables and subroutines; packages do. Or to be specific, packages can export variables and subroutines to the main package.

You can use a module as a straight-forward include. Simply list the material you want and it will be including in the package where the 'use' command is.

In the main file:

use MyUseList;

Create a file called MyUseList.pm and add your list.

#!/usr/bin/perl

use strict;
use warnings;

# Your list goes here

1;  # Modules must return a non-false value
__END__


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to