From: Autrijus Tang Date: Fri, 24 Jan 2003 22:39:06 +0000 (+0000) Subject: fix for C< use if qw/ 1 open :utf8 / > based on: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b97616431c42ffbbb12f97bf297caee34b9f27a9;p=p5sagit%2Fp5-mst-13.2.git fix for C< use if qw/ 1 open :utf8 / > based on: Subject: [perl #20536] use if 1, open => ':utf8' fails From: Autrijus Tang (via RT) Message-Id: p4raw-id: //depot/perl@18684 --- diff --git a/lib/if.pm b/lib/if.pm index 0795dee..6574d97 100644 --- a/lib/if.pm +++ b/lib/if.pm @@ -1,13 +1,14 @@ package if; -our $VERSION = '0.02'; +our $VERSION = '0.03'; sub work { my $method = shift() ? 'import' : 'unimport'; return unless shift; # CONDITION my $p = $_[0]; # PACKAGE - eval "require $p" or die; # Adds .pm etc if needed + (my $file = "$p.pm") =~ s!::!/!g; + require $file or die; my $m = $p->can($method); goto &$m if $m; diff --git a/lib/if.t b/lib/if.t index 3e75718..61cc4b2 100644 --- a/lib/if.t +++ b/lib/if.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -use Test::More tests => 5; +use Test::More tests => 6; my $v_plus = $] + 1; my $v_minus = $] - 1; @@ -27,3 +27,5 @@ ok( (not defined eval "use if ($v_plus > \$]), strict => 'refs'; \${'f'} = 12" ok( eval "use if 1, Cwd; cwd() || 1;", '"use if" with a true condition, module, no arguments, exports'); +ok( eval "use if qw/ 1 if 1 strict subs /; \${'f'} = 12" eq 12, + '"use if" with a module named after keyword');