On Wed, Dec 05, 2001 at 10:14:12AM -0500, Sam Tregar wrote:

>param() will give you the top-level names, query() will get you into
>loops.  It should be easy to write a recursive subroutine that uses
>query() to build up a flat list of param names.  Give it a try and if you
>get stuck post what you've got to the list and I'll help.

I posted this to the list a while ago:

my $t=HTML::Template->new('filename' => $ARGV[0]);

my @l=$t->param;
my @o;
&output(0,\@o,\@l);

sub output {
  my ($level,$oldref,$listref)=@_;
  my @list=@{$listref};
  my @old=@{$oldref};
  foreach my $param (sort @list) {
    my @k=@old;
    push @k,$param;
    print ' ' x $level;
    print "$param\n";
    if ($t->query('name' => \@k) eq 'LOOP') {
      my @l=$t->query('loop' => \@k);
      &output($level+1,\@k,\@l);
    }
  }
}

Roger

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to