MSYS: Update sed to a version that can handle filter-branch examples
[msysgit.git] / lib / perl5 / 5.8.8 / if.pm
blob5f6bcc8ae16cfc8af3869a681613002b1b3c6af7
1 package if;
3 $VERSION = '0.05';
5 sub work {
6 my $method = shift() ? 'import' : 'unimport';
7 die "Too few arguments to `use if' (some code returning an empty list in list context?)"
8 unless @_ >= 2;
9 return unless shift; # CONDITION
11 my $p = $_[0]; # PACKAGE
12 (my $file = "$p.pm") =~ s!::!/!g;
13 require $file; # Works even if $_[0] is a keyword (like open)
14 my $m = $p->can($method);
15 goto &$m if $m;
18 sub import { shift; unshift @_, 1; goto &work }
19 sub unimport { shift; unshift @_, 0; goto &work }
22 __END__
24 =head1 NAME
26 if - C<use> a Perl module if a condition holds
28 =head1 SYNOPSIS
30 use if CONDITION, MODULE => ARGUMENTS;
32 =head1 DESCRIPTION
34 The construct
36 use if CONDITION, MODULE => ARGUMENTS;
38 has no effect unless C<CONDITION> is true. In this case the effect is
39 the same as of
41 use MODULE ARGUMENTS;
43 Above C<< => >> provides necessary quoting of C<MODULE>. If not used (e.g.,
44 no ARGUMENTS to give), you'd better quote C<MODULE> yourselves.
46 =head1 BUGS
48 The current implementation does not allow specification of the
49 required version of the module.
51 =head1 AUTHOR
53 Ilya Zakharevich L<mailto:perl-module-if@ilyaz.org>.
55 =cut