aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-03-11 09:02:29 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-03-11 09:02:29 +0200
commit57a4565ce5bce0a1f2ecb08a80781783e05105bc (patch)
tree2906d1717691e0bdd148944a3c1e78d343d72103
parenta3eda147283ea4c55e6a5367104905fe577ee485 (diff)
downloadregexp-opt-57a4565ce5bce0a1f2ecb08a80781783e05105bc.tar.gz
regexp-opt-57a4565ce5bce0a1f2ecb08a80781783e05105bc.tar.bz2
Minor improvement
* lib/List/Regexp.pm (regexp_opt): Remove duplicates.
-rw-r--r--lib/List/Regexp.pm9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/List/Regexp.pm b/lib/List/Regexp.pm
index 1af9134..76e4a7f 100644
--- a/lib/List/Regexp.pm
+++ b/lib/List/Regexp.pm
@@ -380,6 +380,10 @@ If B<word>, the expression will match single words only.
=item B<debug> => B<0>|B<1>
If B<1>, enable debugging output.
+
+=item B<group> => B<0>|B<1>
+
+If B<1>, enclose entire regexp in a group.
=back
@@ -400,8 +404,9 @@ sub regexp_opt {
unless exists $transtab{$opts->{type}};
$trans = $transtab{$opts->{type}};
}
-
- my @t = map { my @x = split //, $_; \@x } sort @_;
+
+ my %h = map { $_, 1 } @_; # Make sure there are no duplicates
+ my @t = map { my @x = split //, $_; \@x } sort keys %h;
my $tree = parse(@t);
unshift @{$tree}, T_ALT;
print Data::Dumper->Dump([$tree], [qw(tree)]) if ($opts->{debug});

Return to:

Send suggestions and report system problems to the System administrator.