[Israel.pm] question about compiler

Yuval Kogman nothingmuch at woobling.org
Thu Nov 24 05:32:59 PST 2005

On Thu, Nov 24, 2005 at 15:21:51 +0200, Levenglick Dov-RM07994 wrote:
> Hi,
> I have a package that I wrote (Foo) and now want to reuse. The problem is that it uses another package (Bar) that was existent for the application that Foo was originally written for, but not for the current one.
> Is there a way for me to conditionally use Bar?
> package Foo;
> If <condition>
> use Bar;
> Endif 

use if $condition 'Bar';

or more "manually":

	if ( $condition ) {
		require Bar;

Here's a snip from perldoc -f use:

	Imports some semantics into the current package from the named module,
	generally by aliasing certain subroutine or variable names into your
	package.  It is exactly equivalent to

	    BEGIN { require Module; import Module LIST; }

 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me groks YAML like the grasshopper: neeyah!!!!!!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20051124/5174b860/attachment.pgp 

More information about the Perl mailing list