Everything you are doing looks ok, except as you noted you need to
use [% u.domains.$d.status %] rather than [% u.domains.d.status %].

Attached is a short test program that produces the expected results
(with plain hashes).

If $u->{domains} is a blessed reference then the keys operator
(ie: u.domains.keys) will not work (this could be readily fixed
but is a debatable feature; comments anyone?).  You appear to
have solved that problem already by doing the keys in perl. You
could also solve the problem by copying the bless object to a
plain hash (or as a hack blessing it to a 'HASH').  But in any
case the references to members should work fine.  So I can't see
a problem with what you are doing.

One debugging suggestion is to use the Dumper plugin.  This allows
you do dump variables out to see exactly what is going on, eg:

[%
    USE Dumper;
    d = "domain.com";
    Dumper.dump(u);
    Dumper.dump(u.domains);
    Dumper.dump(u.domains.$d);
    Dumper.dump(u.domains.$d.status);
%]

If you don't succeed please post a short, complete test program.

(BTW, since you have periods in your hash keys you cannot write
things like u.domains.domain.com.status.  To access the hash
you need to use an interpolated variable, as you are already.)

HTH,
Craig

use Template;
Template->new()->process(\*DATA, {
        u => {
            domains => {
                "domain.com" => {
                    domain => 'domain.com',
                    status => 'active'
                },
                "domain2.com" => {
                    domain => 'domain2.com',
                    status => 'inactive'
                },
            },
        },
    });

__DATA__
[% FOREACH p = u.domains.keys; -%]
[% p %] => [% u.domains.$p.status %]
[% END -%]


Reply via email to