in reply to A hash slice but not..
Wouldn't you know it.. 10minutes after I send this, I remember eval! DOH! Following is what I've now come up with. Maybe someone has a better solution though.
#!/app/perl5.005/bin/perl use strict; use Data::Dumper; sub add2hash { my($hash,$value,@tree)=@_; my $tree='$hash->{'.join('}{',@tree)."}=$value"; eval $tree; } my(%tree); add2hash(\%tree,1,('a'..'c')); add2hash(\%tree,2,('a','b','d')); print Dumper(\%tree);
Regards,
Shawn M Ferris
Oracle DBA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A hash slice but not..
by merlyn (Sage) on Feb 15, 2001 at 00:59 UTC | |
|
Re: Re: A hash slice but not..
by extremely (Priest) on Feb 15, 2001 at 00:40 UTC |