I think I remember something from the Perl book.

for my $key (keys %hash){

while(ref $_ eq HASH){
do stuff...
}
}


On Thu, Nov 13, 2008 at 3:42 PM, Josh Rosenbaum <[EMAIL PROTECTED]> wrote:

> Todd Rinaldo wrote:
> > What we discovered we need to do is this
> > defined fee && fee.defined('fi') && fee.fi.defined('fo') &&
> > fee.fi.fo.defined('fum')
> >
> > To make things more dificult, the length of the nest isn't always the
> > same. For instance, we might need to test if fee.fi.fo.fum.foo.bar is
> > defined.
> >
> > My question: Is there any easy way to make a recursive block that can
> > test if an unpredictably deep hash is defined?
>
> Ok, I don't really have a good picture of your exact situation and you may
> have already thought of this since it seems pretty simple. I'll throw it out
> there anyway.
>
> *) You might be able to simplify that .defined() stuff. You don't need to
> use the defined test until the very last item:
>
> [% IF a.b.c.d.e && a.b.c.d.e.defined('f') %]
>
> *) If necessary, you could always use a WHILE statement to traverse
> through. That in combination with the following could help.
>
> *) You could also create a BLOCK that will output a value if your
> conditions are true.
>
> [% a = PROCESS my_test_block %]
> [% IF a %]do stuff [% END %]
> [% BLOCK my_test_block %]do test here that will output something if
> correct[% END %]
>
> -- Josh
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>



-- 
Kelly A. Thompson
Midland Trail Scenic Highway Association
237 Capitol Street
Charleston, West Virginia 25301
p: 304.343.6001
f:  304.344.2210
www.midlandtrail.com

Adventure begins at the exit ramp. Travel the Midland Trail.
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to