Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The only real innovation is using only one hash, and using the tier indices to avoid the backing up.

    use strict;
    use warnings;

    use Data::Dumper;

    my $hash = {};

    set_multi_level_hash($hash, [qw/ a b c d /], 'potato');

    print Dumper $hash;

    sub set_multi_level_hash
          {
          my ( $hash, $tiers, $value ) = @_;

          for (0 .. $#$tiers)
                {
                $hash->{$tiers->[$_]} ||= ( $_ == $#$t