6 my $method = shift() ? 'import' : 'unimport';
7 return unless shift; # CONDITION
9 my $p = $_[0]; # PACKAGE
10 (my $file = "$p.pm") =~ s!::!/!g;
11 require $file; # Works even if $_[0] is a keyword (like open)
12 my $m = $p->can($method);
16 sub import { shift; unshift @_, 1; goto &work }
17 sub unimport { shift; unshift @_, 0; goto &work }
24 if - C<use> a Perl module if a condition holds
28 use if CONDITION, MODULE => ARGUMENTS;
34 use if CONDITION, MODULE => ARGUMENTS;
36 has no effect unless C<CONDITION> is true. In this case the effect is
43 The current implementation does not allow specification of the
44 required version of the module.
48 Ilya Zakharevich L<mailto:perl-module-if@ilyaz.org>.