use strict;
use warnings;
-use Carp qw/croak/;
-use Text::Balanced qw/extract_bracketed/;
+use Carp qw<croak>;
+use Text::Balanced qw<extract_bracketed>;
=head1 NAME
=cut
-use vars qw/$VERSION/;
+use vars qw<$VERSION>;
BEGIN {
$VERSION = '1.03';
}
$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<jokers brackets> ], # Do jokers and brackets.
+ capture => [ qw<any greedy> ], # 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<greedy> ]); # Actually we want non-greedy matches.
$re = $rw->convert('*a{,(b)?}?c*'); # '(.*?)a(?:|(b).).c(.*?)'
$rw->capture(); # No more captures.
}
my %types = (
- jokers => [ qw/jokers/ ],
- sql => [ qw/sql/ ],
- commas => [ qw/commas/ ],
- brackets => [ qw/brackets/ ],
- unix => [ qw/jokers brackets/ ],
- win32 => [ qw/jokers commas/ ],
+ jokers => [ qw<jokers> ],
+ sql => [ qw<sql> ],
+ commas => [ qw<commas> ],
+ brackets => [ qw<brackets> ],
+ unix => [ qw<jokers brackets> ],
+ win32 => [ qw<jokers commas> ],
);
-$types{$_} = $types{win32} for qw/dos os2 MSWin32 cygwin/;
-$types{$_} = $types{unix} for qw/linux
+$types{$_} = $types{win32} for qw<dos os2 MSWin32 cygwin>;
+$types{$_} = $types{unix} for qw<linux
darwin machten next
aix irix hpux dgux dynixptx
bsdos freebsd openbsd
svr4 solaris sunos dec_osf
- sco_sv unicos unicosmk/;
+ sco_sv unicos unicosmk>;
my %escapes = (
jokers => '?*',
}
my %checked;
- for (qw/set add rem/) {
+ for (qw<set add rem>) {
my $opt = $opts{$_};
next unless defined $opt;
my $cb = {
$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<sql commas> ]); # Translate also SQL and commas.
$rw->do(rem => 'jokers'); # Specifying both 'sql' and 'jokers' is useless.
$rw->do(); # Translate nothing.
$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<any greedy> ]); # Also greedily capture "any" metacharacters.
$rw->capture(rem => 'greedy'); # No more greed please.
$rw->capture(); # Capture nothing.
use strict;
use warnings;
-use lib qw{blib/lib};
+use lib qw<blib/lib>;
use Regexp::Wildcards;
use Data::Dumper;
my $rw = Regexp::Wildcards->new(
- do => [ qw/brackets/ ],
- capture => [ qw/single/ ],
+ do => [ qw<brackets> ],
+ capture => [ qw<single> ],
);
-$rw->do(add => [ qw/jokers/ ]);
-$rw->capture(add => [ qw/brackets any greedy/ ]);
+$rw->do(add => [ qw<jokers> ]);
+$rw->capture(add => [ qw<brackets any greedy> ]);
print $_, ' => ', $rw->convert($_), "\n" for @ARGV;
require Regexp::Wildcards;
-for (qw/new do capture type convert/) {
+for (qw<new do capture type convert>) {
ok(Regexp::Wildcards->can($_), 'RW can ' . $_);
}
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<a b c>) };
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<do capture type convert>) {
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<do capture>) {
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<a b c>) };
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");
}
eval { $rw->convert(undef, 'again monkey!') };
like($@, qr/Wrong\s+type/, 'RW::convert wants a type it knows');
-for (qw/convert/) {
+for (qw<convert>) {
ok(!defined $rw->$_(undef), "RW::$_ returns undef when passed undef");
}
$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<jokers> ], 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');
try $rw, "multiple capturing $one", $one.$one.'\\'.$one.$one,
'(.)(.)\\'.$one.'(.)';
- $rw->capture(add => [ qw/any greedy/ ]);
+ $rw->capture(add => [ qw<any greedy> ]);
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<any greedy> ]);
try $rw, "multiple capturing $any (greedy) and non-capturing $one",
$wc, '(.*)..\\'.$one.'.\\'.$any.'(.*)';
alltests 'jokers', '?', '*';
alltests 'sql', '_', '%';
-alltests [ qw/jokers sql/ ], '_', '*';
+alltests [ qw<jokers sql> ], '_', '*';
use Regexp::Wildcards;
-my $rw = Regexp::Wildcards->new(qw/do brackets/);
+my $rw = Regexp::Wildcards->new(qw<do brackets>);
is($rw->convert('a{b\\\\,c\\\\}d', 'jokers'), 'a\\{b\\\\\\,c\\\\\\}d','jokers');
use Regexp::Wildcards;
-my $rw = Regexp::Wildcards->new(do => [ qw/jokers brackets groups/ ]);
+my $rw = Regexp::Wildcards->new(do => [ qw<jokers brackets groups> ]);
is($rw->convert('a(?)b'), 'a(.)b', 'groups: single');
is($rw->convert('a(*)b'), 'a(.*)b', 'groups: any');