<div dir="ltr">Reporting in!<div><br></div><div style>All of these methods worked really well.</div><div style><br></div><div style>Data::Dumper.  Intriguing that it works, I never would have thought about it.  In a post on stack overflow, Schwern mentions that Data::Serializer is a better way to go (thought I didn't try it).</div>
<div style><br></div><div style>Data::Visitor::Callback.  The most elegant solution.  I love that there's a module for this, and it does what it says on the box.</div><div style><br></div><div style>YAML.  Probably what we'll go with, since it's a technique that we're using elsewhere in this library, and clearly performance isn't a concern there.</div>
<div style><br></div><div style>Thanks everyone for your suggestions.  This is why I love this community.</div><div style><br></div><div style>J</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Jun 15, 2013 at 1:02 PM, Jason Messer <span dir="ltr"><<a href="mailto:jasoncmesser@gmail.com" target="_blank">jasoncmesser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>I somewhat regularly use something like the following</div><div><br></div><div>use Data::Dumper;<br></div><div>$Data::Dumper::Terse = 1;</div><div><br></div><div>$foo = {</div><div>        'onexx' => 1,</div>

<div>        'twoxx' => 2,</div><div>        'threexx' => 3,</div><div>        'fourxx' => ["axxb", "xbx", 'c', 'x', "d", "e", 'f', 42],</div>

<div>        'inc' => \@INC,</div><div>        'env' => \%ENV</div><div>};</div><div><br></div><div>$x = Dumper($foo);</div><div><br></div><div>$x =~ s/xx/__XX__/g;</div><div>$x =~ s/perl/##PERL##/g;</div>

<div>$e = eval($x);</div><div>print Dumper($e)</div><div><br></div><div>This has the advantage of simplicity, you can dump the string to a file and monkey with it with an editor before evaling it back.</div><div>
<br></div><div>It has all the problems of unstructured text, and it's definitely on the quick and dirty side of performance considerations, but it works and is simple.</div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-Jason</div>
<div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 15, 2013 at 12:32 PM, Josh Heumann <span dir="ltr"><<a href="mailto:pdx.pm@joshheumann.com" target="_blank">pdx.pm@joshheumann.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">To be more clear, searching hash keys isn't required as the string will have a sigil to identify strings to be interpolated, but if the strategy avoided looking at hash keys, that would help avoid potentially catastrophic mistakes.<span><font color="#888888"><div>


<br></div><div>J</div></font></span></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Sat, Jun 15, 2013 at 11:22 AM, benh <span dir="ltr"><<a href="mailto:ben.hengst@gmail.com" target="_blank">ben.hengst@gmail.com</a>></span> wrote:<br>


</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I agree though in my reading that is an expected feature:<br>
<div><br>
> ...would replace foo with bar in all strings at all levels.<br>
<br>
</div>Though again I could also be completely missing the intent here so it<br>
is a completely fair thing to mention.<br>
<div><div><br>
On Sat, Jun 15, 2013 at 10:10 AM, Braden Kelley <<a href="mailto:bmk@rentrak.com" target="_blank">bmk@rentrak.com</a>> wrote:<br>
> One potential problem with serializing using something like JSON::XS is a<br>
> simple regex replace would also end up replacing hash keys, not just their<br>
> values.<br>
><br>
> # 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" target="_blank">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>
><br>
> _______________________________________________<br>
> Pdx-pm-list mailing list<br>
> <a href="mailto:Pdx-pm-list@pm.org" target="_blank">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>
<br>
<br>
<br>
</div></div><div>--<br>
benh~<br>
<br>
<a href="http://about.notbenh.info" target="_blank">http://about.notbenh.info</a><br>
<br>
Stability is not a Regression.<br>
</div><div><div>_______________________________________________<br>
Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org" target="_blank">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>
<br>
</div></div></blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org" target="_blank">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></blockquote></div><br></div>
</div></div><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></blockquote></div><br></div>