ClickToViewInfo has asked for the wisdom of the Perl Monks concerning the following question:
$cats->{'~cat_list'} is then passed into HTML::Template.sub BuildCatList { my @cat_list = (); my $cats = &main::GetDB('cats'); # a ref to a tied BerkeleyDB hash local *get_next_lvl = sub { my ($cat_id, $depth) = @_; my %cache = (); my $cat_info = Category->new($cat_id); defined $cat_info or warn "no such cat '$cat_id'" && return undef; foreach my $id (@{$cat_info->field('sub_cats')}) { my $subcat_info = Category->new($id); defined $subcat_info or warn "no such cat '$id'" && next; $cache{$id} = $subcat_info->field('name'); } foreach my $id (sort {$cache{$a} cmp $cache{$b}} keys %cache) { push (@cat_list, { depth => $depth , id => $id , name => '. . ' x $depth . $cache{$id} }); defined get_next_lvl($id, $depth+1) or warn "undef ret" && return undef; } return 1; }; push(@cat_list, {id => 'top', name => 'Top', depth => 0} ); defined get_next_lvl('top', 1) or warn "undef ret" && return undef; $cats->{'~cat_list'} = &main::nfreeze( \@cat_list ); return 1; }
----------------------------------
Here's some of Google's Wizdom (Google Glossary):
Stupid: Losing $25 on the game and $25 on the instant replay.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing a dir tree
by dpuu (Chaplain) on Jul 21, 2002 at 03:02 UTC | |
by ClickToViewInfo (Initiate) on Jul 22, 2002 at 01:50 UTC | |
by dpuu (Chaplain) on Jul 22, 2002 at 02:57 UTC | |
by ClickToViewInfo (Initiate) on Jul 27, 2002 at 05:42 UTC |