From 594eebf78b0d5f8243de2f923025e7aade5db296 Mon Sep 17 00:00:00 2001 From: Ben Moon Date: Mon, 11 Jul 2016 11:27:38 +0100 Subject: [PATCH] Ensure no name collisions for supported parens --- lib/DDG/GoodieRole/Parse/List.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DDG/GoodieRole/Parse/List.pm b/lib/DDG/GoodieRole/Parse/List.pm index 7e0b7fd3caa..58fa4e6b532 100644 --- a/lib/DDG/GoodieRole/Parse/List.pm +++ b/lib/DDG/GoodieRole/Parse/List.pm @@ -9,7 +9,7 @@ use List::Util qw( all pairs ); use Data::Record; use Regexp::Common; -my @parens = ( +my @supported_parens = ( '[' => ']', '(' => ')', '{' => '}', @@ -28,7 +28,7 @@ sub get_separator { sub remove_parens { my $text = shift; - foreach (pairs @parens) { + foreach (pairs @supported_parens) { my ($opening, $closing) = map { quotemeta $_ } @$_; next unless $text =~ /^$RE{balanced}{-parens=>"$opening$closing"}$/; $text =~ s/^$opening(.*?)$closing$/$1/; @@ -106,7 +106,7 @@ sub format_list { my $parens = $options{parens} // '[]'; my $join = $options{join} // ', '; my $join_last = $options{join_last} // $join; - @parens = ref $parens eq 'ARRAY' + my @parens = ref $parens eq 'ARRAY' ? @$parens : split '', $parens; # In the case the user uses parens => '' we don't want to # display *any* parentheses, so we need to have 'fake'