<html><head></head><body bgcolor="#FFFFFF"><div>Just hope the OP doesn't exceed the recursion limit ;)</div><div><br></div><div>Now we just need someone to post a loop version, and we'll be done.<br><br>Cheers,<div>Shaun</div></div><div><br>On Apr 13, 2013, at 4:11 PM, Richard Dice <<a href="mailto:rdice@pobox.com">rdice@pobox.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div><div dir="ltr"><div style="">My solution is to go recursive...</div><div><br></div><div>richard-dice-s-computer-9:Desktop rdice$ cat ./<a href="http://hashkeys.pl">hashkeys.pl</a></div><div>#!/usr/bin/env perl</div><div><br></div>
<div>use warnings;</div><div>use strict;</div><div><br></div><div>use Data::Dumper qw ( Dumper );</div><div><br></div><div>my $conf;</div><div><br></div><div>$conf->{foo}{bar} = "a";</div><div>$conf->{baz} = "1";</div>
<div>$conf->{this}{and}{the}{other}{thing} = "what?";</div><div><br></div><div>my @joinkeys = qw (</div><div>foo::bar</div><div>baz</div><div>this::and::the::other::thing</div><div>);</div><div><br></div><div>
foreach my $joinkey ( @joinkeys ) {</div><div>  my @bits = split /::/, $joinkey;</div><div>  print hashval($conf, \@bits);</div><div>  print "\n";</div><div>}</div><div><br></div><div>exit 0;</div><div><br></div>
<div>sub hashval {</div><div>  my ($hash, $keybits) = @_;</div><div>  if ( ref($hash->{$keybits->[0]}) eq 'HASH' ) {<br></div><div>    return hashval($hash->{$keybits->[0]}, [ @$keybits[1..$#$keybits]]);</div>
<div>  } elsif ( ! ref($hash->{$keybits->[0]}) ) {</div><div>    return $hash->{$keybits->[0]};</div><div>  } else {</div><div>    die "Foo! They key string you gave me doesn't correspond to a known proper hash-of-hash entry within the 'conf' structure --> "  . Dumper($hash, $keybits);</div>
<div>  }</div><div>}</div><div>richard-dice-s-computer-9:Desktop rdice$  ./<a href="http://hashkeys.pl">hashkeys.pl</a></div><div>a</div><div>1</div><div>what?</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Apr 13, 2013 at 1:29 AM, Digimer <span dir="ltr"><<a href="mailto:lists@alteeve.ca" target="_blank">lists@alteeve.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
  I've got a rather large, random-depth hash. ie:<br>
<br>
$conf->{foo}{bar} = "a";<br>
$conf->{baz} = "1";<br>
$conf->{this}{and}{the}{other}<u></u>{thing} = "what?";<br>
<br>
  And so on. The number of hash keys can be quite varied, depending on the use.<br>
<br>
  So now I want to be able to take a string that is in the format:<br>
<br>
foo::bar<br>
baz<br>
this::and::the::other::thing<br>
<br>
  Split on the :: and use that to pull the value out of the hash.<br>
<br>
Any help would be much appreciated! :)<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Digimer<br>
Papers and Projects: <a href="https://alteeve.ca/w/" target="_blank">https://alteeve.ca/w/</a><br>
What if the cure for cancer is trapped in the mind of a person without access to education?<br>
______________________________<u></u>_________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/toronto-pm</a><br>
</font></span></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>toronto-pm mailing list</span><br><span><a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a></span><br><span><a href="http://mail.pm.org/mailman/listinfo/toronto-pm">http://mail.pm.org/mailman/listinfo/toronto-pm</a></span><br></div></blockquote></body></html>