Merge pull request #1153 from mbethke/fix-unixsock
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 5 Aug 2015 09:08:22 +0000 (11:08 +0200)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 5 Aug 2015 09:08:22 +0000 (11:08 +0200)
Fix Unixsock.pm

bindings/perl/lib/Collectd/Unixsock.pm
bindings/perl/t/01_methods.t

index 5c6a5f9..69c755b 100644 (file)
@@ -137,13 +137,13 @@ sub _parse_identifier
 
 sub _escape_argument
 {
-       local $_ = shift;
+    my $arg = shift;
 
-       return $_ if /^\w+$/;
+       return $arg if $arg =~ /^\w+$/;
 
-       s#\\#\\\\#g;
-       s#"#\\"#g;
-       return "\"$_\"";
+       $arg =~ s#\\#\\\\#g;
+       $arg =~ s#"#\\"#g;
+       return "\"$arg\"";
 }
 
 # Send a command on a socket, including any required argument escaping.
index 2f7818b..4e94f8e 100644 (file)
@@ -16,7 +16,7 @@ sub test_query {
     my ($nresults, $resultdata) = @$results;
     my $r = $s->getval(%{Collectd::Unixsock::_parse_identifier($attr)});
     is(ref $r, 'HASH', "Got a result for $attr");
-    is(scalar keys $r, $nresults, "$nresults result result for $attr");
+    is(scalar keys %$r, $nresults, "$nresults result result for $attr");
     is_deeply($r, $resultdata, "Data or $attr matches");
 }