Code

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 5c6a5f9d24c74179b8c2e3a878619198398bdc73..69c755b6a92996cd192b9845ea87c866dd51b741 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.