From a1ce9696c929aeaf1738cf281f4241d100525341 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 17 Apr 2019 22:15:59 +1200 Subject: ListParser: enable strict, implement escape character --- ListParser.pm | 13 ++++++++++--- Plugin/Admin.pm | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ListParser.pm b/ListParser.pm index 099b1a1..57e0a62 100644 --- a/ListParser.pm +++ b/ListParser.pm @@ -1,10 +1,13 @@ package ListParser; +use strict; +use warnings; + sub parse_mapping { my ($input) = @_; - my $key, $value; + my ($key, $value); my $i = 0; - my $string_start, $string_end; + my ($string_start, $string_end); $string_start = $string_end = undef; # Are we currently lexing inside a string literal? @@ -67,6 +70,7 @@ sub parse_list { my $c_start = $is_hash ? "{" : "["; my $c_end = $is_hash ? "}" : "]"; my %h_res; + my %mapping; my @a_res; my $i = 0; @@ -86,7 +90,10 @@ sub parse_list { while ($nest != 0 && $i < length($input)) { my $c = substr($input, $i, 1); - if ($c eq $c_start) { + if ($c eq "\\") { + substr($input, $i, 1) = ""; + $i++; + } elsif ($c eq $c_start) { $nest++; } elsif ($c eq $c_end) { $nest--; diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm index a5217f7..ce43424 100644 --- a/Plugin/Admin.pm +++ b/Plugin/Admin.pm @@ -44,7 +44,6 @@ sub configure { $cmdref->($self, "load", sub { $self->load_plugin(@_); } ); $cmdref->($self, "unload", sub { $self->unload_plugin(@_); } ); - return $self; } -- cgit v1.1