On Wed, Feb 05, 2003 at 09:53:28AM +0000, Roger Burton West wrote: > On Wed, Feb 05, 2003 at 01:31:21AM -0800, Randy J. Ray wrote: > >$s = $r; > >for (@list) { $s = $s->{$_}; last unless ref $s; } > >There's probably a trickier, shorter "golf" solution, but I was never into > >obfuscated code writing... > > That makes sense; I was looking for a single-step transformation...
Single statement, $ perl -MData::Dumper -le '@r=qw(foo bar baz qux); eval q{\$h->}.join"",map"{$_}",@r; print Dumper($h)' $VAR1 = { 'foo' => { 'bar' => { 'baz' => { 'qux' => undef } } } }; $ >:-) P -- Paul Makepeace ....................................... http://paulm.com/ "If only it were so, then put it down. It's not yours anyway." -- http://paulm.com/toys/surrealism/