## This code block causes problems use vars qw/ $g /; # or, "our $g;" sub doit_local { local $g = shift; $g =~ s/'/'\''/g; return $g; } sub get_md5sums { my $x = shift; print Dumper [$x, $$x{path}]; for $g ('find', $$x{path}, qw/-type f -exec md5sum {} ;/) { $$x{foo} .= '"'.doit_local($g).'"'; } return 1; } #### ## This code block works as expected use vars qw/ $g /; # or, "our $g;" sub doit_local { local $g = shift; $g =~ s/'/'\''/g; return $g; } sub get_md5sums { my $x = shift; print Dumper [$x, $$x{path}]; for ('find', $$x{path}, qw/-type f -exec md5sum {} ;/) { $g = $_; $$x{foo} .= '"'.doit_local($g).'"'; } return 1; }