From: Vincent Pit Date: Thu, 25 Aug 2011 11:17:26 +0000 (+0200) Subject: Switch to qw<> X-Git-Tag: v1.04~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=152b316b711f68b0027cbdd3e231bb6cd3d9b9a5;p=perl%2Fmodules%2FRegexp-Wildcards.git Switch to qw<> --- diff --git a/lib/Regexp/Wildcards.pm b/lib/Regexp/Wildcards.pm index d0f9ab3..8d79b93 100644 --- a/lib/Regexp/Wildcards.pm +++ b/lib/Regexp/Wildcards.pm @@ -3,8 +3,8 @@ package Regexp::Wildcards; use strict; use warnings; -use Carp qw/croak/; -use Text::Balanced qw/extract_bracketed/; +use Carp qw; +use Text::Balanced qw; =head1 NAME @@ -16,7 +16,7 @@ Version 1.03 =cut -use vars qw/$VERSION/; +use vars qw<$VERSION>; BEGIN { $VERSION = '1.03'; } @@ -34,12 +34,12 @@ BEGIN { $re = $rw->convert('%a_c%', 'sql'); # Turn SQL wildcards into regexps. $rw = Regexp::Wildcards->new( - do => [ qw/jokers brackets/ ], # Do jokers and brackets. - capture => [ qw/any greedy/ ], # Capture *'s greedily. + do => [ qw ], # Do jokers and brackets. + capture => [ qw ], # Capture *'s greedily. ); $rw->do(add => 'groups'); # Don't escape groups. - $rw->capture(rem => [ qw/greedy/ ]); # Actually we want non-greedy matches. + $rw->capture(rem => [ qw ]); # Actually we want non-greedy matches. $re = $rw->convert('*a{,(b)?}?c*'); # '(.*?)a(?:|(b).).c(.*?)' $rw->capture(); # No more captures. @@ -65,20 +65,20 @@ sub _check_self { } my %types = ( - jokers => [ qw/jokers/ ], - sql => [ qw/sql/ ], - commas => [ qw/commas/ ], - brackets => [ qw/brackets/ ], - unix => [ qw/jokers brackets/ ], - win32 => [ qw/jokers commas/ ], + jokers => [ qw ], + sql => [ qw ], + commas => [ qw ], + brackets => [ qw ], + unix => [ qw ], + win32 => [ qw ], ); -$types{$_} = $types{win32} for qw/dos os2 MSWin32 cygwin/; -$types{$_} = $types{unix} for qw/linux +$types{$_} = $types{win32} for qw; +$types{$_} = $types{unix} for qw; my %escapes = ( jokers => '?*', @@ -115,7 +115,7 @@ sub _validate { } my %checked; - for (qw/set add rem/) { + for (qw) { my $opt = $opts{$_}; next unless defined $opt; my $cb = { @@ -310,7 +310,7 @@ No argument means C<< set => [ ] >>. $rw->do(set => 'jokers'); # Only translate jokers. $rw->do('jokers'); # Same. - $rw->do(add => [ qw/sql commas/ ]); # Translate also SQL and commas. + $rw->do(add => [ qw ]); # Translate also SQL and commas. $rw->do(rem => 'jokers'); # Specifying both 'sql' and 'jokers' is useless. $rw->do(); # Translate nothing. @@ -415,7 +415,7 @@ Capture matching C<{ ... , ... }> alternations. $rw->capture(set => 'single'); # Only capture "exactly one" metacharacters. $rw->capture('single'); # Same. - $rw->capture(add => [ qw/any greedy/ ]); # Also greedily capture "any" metacharacters. + $rw->capture(add => [ qw ]); # Also greedily capture "any" metacharacters. $rw->capture(rem => 'greedy'); # No more greed please. $rw->capture(); # Capture nothing. diff --git a/samples/wc2re.pl b/samples/wc2re.pl index b3336f7..2960316 100755 --- a/samples/wc2re.pl +++ b/samples/wc2re.pl @@ -3,16 +3,16 @@ use strict; use warnings; -use lib qw{blib/lib}; +use lib qw; use Regexp::Wildcards; use Data::Dumper; my $rw = Regexp::Wildcards->new( - do => [ qw/brackets/ ], - capture => [ qw/single/ ], + do => [ qw ], + capture => [ qw ], ); -$rw->do(add => [ qw/jokers/ ]); -$rw->capture(add => [ qw/brackets any greedy/ ]); +$rw->do(add => [ qw ]); +$rw->capture(add => [ qw ]); print $_, ' => ', $rw->convert($_), "\n" for @ARGV; diff --git a/t/02-can.t b/t/02-can.t index 35879cb..e5946e7 100644 --- a/t/02-can.t +++ b/t/02-can.t @@ -7,7 +7,7 @@ use Test::More tests => 5; require Regexp::Wildcards; -for (qw/new do capture type convert/) { +for (qw) { ok(Regexp::Wildcards->can($_), 'RW can ' . $_); } diff --git a/t/10-obj.t b/t/10-obj.t index c72ed6a..e88ff8b 100644 --- a/t/10-obj.t +++ b/t/10-obj.t @@ -19,26 +19,26 @@ $rw2 = Regexp::Wildcards::new(); ok(defined $rw2, 'RW::new called without a class works'); is(ref $rw2, 'Regexp::Wildcards', 'RW::new called without a class is valid'); -eval { $rw2 = Regexp::Wildcards->new(qw/a b c/) }; +eval { $rw2 = Regexp::Wildcards->new(qw) }; like($@, qr/Optional\s+arguments/, 'RW::new gets parameters as key => value pairs'); my $fake = { }; bless $fake, 'Regexp::Wildcards::Hlagh'; -for (qw/do capture type convert/) { +for (qw) { eval "Regexp::Wildcards::$_('Regexp::Wildcards')"; like($@, qr/^First\s+argument/, "RW::$_ isn't a class method"); eval "Regexp::Wildcards::$_(\$fake)"; like($@, qr/^First\s+argument/, "RW::$_ only applies to RW objects"); } -for (qw/do capture/) { +for (qw) { eval { $rw->$_(sub { 'dongs' }) }; like($@, qr/Wrong\s+option\s+set/, "RW::$_ don't want code references"); eval { $rw->$_(\*STDERR) }; like($@, qr/Wrong\s+option\s+set/, "RW::$_ don't want globs"); - eval { $rw->$_(qw/a b c/) }; + eval { $rw->$_(qw) }; like($@, qr/Arguments\s+must\s+be\s+passed.*unique\s+scalar.*key\s+=>\s+value\s+pairs/, "RW::$_ gets parameters after the first as key => value pairs"); } @@ -48,6 +48,6 @@ like($@, qr/Wrong\s+type/, 'RW::type wants a type it knows'); eval { $rw->convert(undef, 'again monkey!') }; like($@, qr/Wrong\s+type/, 'RW::convert wants a type it knows'); -for (qw/convert/) { +for (qw) { ok(!defined $rw->$_(undef), "RW::$_ returns undef when passed undef"); } diff --git a/t/11-opts.t b/t/11-opts.t index 1874b77..b2d510c 100644 --- a/t/11-opts.t +++ b/t/11-opts.t @@ -27,7 +27,7 @@ is($rw->convert($wc), $win32, 'reset to win32'); $rw->type(); is($rw->convert($wc), $unix, 'reset to unix'); -$rw = Regexp::Wildcards->new(do => [ qw/jokers/ ], type => 'win32'); +$rw = Regexp::Wildcards->new(do => [ qw ], type => 'win32'); is($rw->convert($wc), $jokers, 'do overrides type in new'); $rw->do(add => 'groups'); is($rw->convert($wc), $jok_gr, 'added groups to jokers'); diff --git a/t/20-jokers.t b/t/20-jokers.t index 262a2aa..8b80608 100644 --- a/t/20-jokers.t +++ b/t/20-jokers.t @@ -55,14 +55,14 @@ sub alltests { try $rw, "multiple capturing $one", $one.$one.'\\'.$one.$one, '(.)(.)\\'.$one.'(.)'; - $rw->capture(add => [ qw/any greedy/ ]); + $rw->capture(add => [ qw ]); try $rw, "multiple capturing $any (greedy)", $any.$any.'\\'.$any.$any, '(.*)\\'.$any.'(.*)'; my $wc = $any.$any.$one.$one.'\\'.$one.$one.'\\'.$any.$any; try $rw, "multiple capturing $any (greedy) and capturing $one", $wc, '(.*)(.)(.)\\'.$one.'(.)\\'.$any.'(.*)'; - $rw->capture(set => [ qw/any greedy/ ]); + $rw->capture(set => [ qw ]); try $rw, "multiple capturing $any (greedy) and non-capturing $one", $wc, '(.*)..\\'.$one.'.\\'.$any.'(.*)'; @@ -106,4 +106,4 @@ sub alltests { alltests 'jokers', '?', '*'; alltests 'sql', '_', '%'; -alltests [ qw/jokers sql/ ], '_', '*'; +alltests [ qw ], '_', '*'; diff --git a/t/22-brackets.t b/t/22-brackets.t index 7585649..caab50a 100644 --- a/t/22-brackets.t +++ b/t/22-brackets.t @@ -7,7 +7,7 @@ use Test::More tests => 27; use Regexp::Wildcards; -my $rw = Regexp::Wildcards->new(qw/do brackets/); +my $rw = Regexp::Wildcards->new(qw); is($rw->convert('a{b\\\\,c\\\\}d', 'jokers'), 'a\\{b\\\\\\,c\\\\\\}d','jokers'); diff --git a/t/23-groups.t b/t/23-groups.t index 9b36dc2..30a1f1b 100644 --- a/t/23-groups.t +++ b/t/23-groups.t @@ -7,7 +7,7 @@ use Test::More tests => 6; use Regexp::Wildcards; -my $rw = Regexp::Wildcards->new(do => [ qw/jokers brackets groups/ ]); +my $rw = Regexp::Wildcards->new(do => [ qw ]); is($rw->convert('a(?)b'), 'a(.)b', 'groups: single'); is($rw->convert('a(*)b'), 'a(.*)b', 'groups: any');