make _escape_argument() readonly-safe on older Perls
authorMatthias Bethke <matthias.bethke@financial.com>
Tue, 21 Jul 2015 08:02:16 +0000 (15:02 +0700)
committerMatthias Bethke <matthias.bethke@financial.com>
Tue, 21 Jul 2015 08:02:16 +0000 (15:02 +0700)
bindings/perl/lib/Collectd/Unixsock.pm

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.