Re: Adding the use statements to a different file
- From: shawn.corey@xxxxxxxxxxxx (Shawn Corey)
- Date: Mon, 28 Nov 2005 13:33:32 -0500
vmalik@xxxxxxxxxxxxxxxxxxxx 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_ .
- Follow-Ups:
- Re: Adding the use statements to a different file
- From: vmalik
- Re: Adding the use statements to a different file
- References:
- Adding the use statements to a different file
- From: vmalik
- Adding the use statements to a different file
- Prev by Date: Re: comparing arrays of strings
- Next by Date: Re: Installing Perl Modules Locally
- Previous by thread: Adding the use statements to a different file
- Next by thread: Re: Adding the use statements to a different file
- Index(es):
Relevant Pages
|
|