<p dir="ltr">One potential problem with serializing using something like JSON::XS is a simple regex replace would also end up replacing hash keys, not just their values.</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># from Josh Heumann on Friday 14 June 2013:<br>
>Using YAML/JSON isn't a bad idea, but I'm worried about the<br>
>performance hit.<br>
<br>
As long as your replacement doesn't break quoting or otherwise trip on<br>
the serialization, yeah.  JSON::XS was super quick and the fastest<br>
serializer last time I checked.  You'll need the ram.<br>
<br>
Recursive implementation is easy enough.<br>
<br>
sub replace_deeply {<br>
  my ($data, $match, $replace) = @_;<br>
  my $r;<br>
  $r = sub {<br>
    my $ref = ref($_[0]) or return $_[0] =~ s/$match/$replace/;<br>
    if($ref eq 'ARRAY') {<br>
      $r->($_) for @{$_[0]}<br>
    }<br>
    elsif($ref eq 'HASH') {<br>
      $r->($_) for values %{$_[0]};<br>
    }<br>
  };<br>
  $r->($data);<br>
  return $data;<br>
}<br>
<br>
--Eric<br>
--<br>
---------------------------------------------------<br>
    <a href="http://scratchcomputing.com" target="_blank">http://scratchcomputing.com</a><br>
---------------------------------------------------<br>
_______________________________________________<br>
Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org">Pdx-pm-list@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a><br>
</div>