hohoa (anything cheaper?)

cabney cabney at cyberpass.net
Sun Jun 10 01:08:01 CDT 2001

k, I don't know if I should be embarrassed about this or not... but can
someone point out a cheaper way of creating an array of token chains?
(one that doesn't compromise code maintenance. :)

The objective is to ensure the length of the chains can vary over a
range... which this datastructure seems to do.  I'm looking for a
perspective not biased like mine might be, or someone's experience...
or just an opportunity to learn something. :)

(uh, I'm also aware i'll have to make some minor changes to allow
arrays anywhere along the chain where needed -- this is just some
test code.)

============================== hohoa.pl ==============================
#! /usr/bin/perl -w

use strict;
use Data::Dumper;

my @hash_elements = ("my","very","earnest","mother","just","served","us","nine","pickles");

my $end = pop @hash_elements;
my $href;

for my $idx ( reverse 0 .. $#hash_elements )
	my $elem = $hash_elements[$idx];
	if ( ref($end) ) {
		$href = { $elem => $end };
	} else {
		$href = { $elem => [$end] };
		#push @{$href->{$elem}}, "foo";
	$end = $href;

print Dumper($href);

============================== hohoa.pl ==============================

There was a time
A wind that blew so young
For this could be the biggest sky
And I could have the faintest idea


The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.

More information about the San-Diego-pm mailing list