in reply to Escaping %params

You can start playing with something like the following:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; sub safer { my $hash = shift; my %safer; while (my ($k, $v) = each %$hash) { s/'/\'/g for $k, $v; $safer{$k} = $v; } return %safer } my %params = ('a b' => 'c d', "a'b" => "c'd", 'a"b' => 'c"d', 'a`b' => 'c`d', "a\\'b" => "a\\'b", ); my %safer = safer(\%params); print Dumper \%safer;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Escaping %params
by DaisyLou (Sexton) on Jan 21, 2014 at 01:30 UTC
    Thank you! Is it necessary to have
    my %safer = safer(\%params);
    or would
    safe(\%params); print Dumper \%params;
    be equally good?
      It might be possible if you changed the definition of the function. You can always do
      %params = safer(\%params);
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Have you tried?