Shawn Corey wrote:
> [EMAIL PROTECTED] wrote:
> 
>> In my script, I load the module by saying "use PerlMQ;". However, now
>> I want to
>> load only certain use statements from the module depending on the
>> parameter I
>> give it. For example, in my script, I want to say "use PerlMQ
>> qw(some_parameter)" in order to load the use statements specified by
>> some_parameter in the module. Is it possible to do that?
> 
> 
> Yes, there are ways.
> 
>>
> ----------------------------------------------------------------------------------
> 
>> #PerlMQ.pm
>>
>> use strict;
>> use warnings;
>>
>> use statement1;
>> use statement2;
>> use statement3;
>>
> 
> # Change to:
> use File::Basename;
> 
> use if ( basename( $0 ) eq 'script1' ), module1 => undef;
> use if ( basename( $0 ) eq 'script1'
>          && basename( $0 ) eq 'script2' ),
>        module2 => undef;
> use if ( basename( $0 ) eq 'script3' ), module3 => undef;
> 
>> #and so on...
>>
>> 1;
>>
>> _END_
>>
> 
> See `perldoc if` for details.
> 

Huh, very nice. Note that is a new pragma in Perl 5.8.

http://danconia.org

-- 
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