Hi,

I ran across what looks like a bug to me, though I suppose it could
be a feature.  :)

When a hash key starts with a dot, I can't figure out how to
retrieve its corresponding value from the hash.  Here's a sample
script to illustrate the problem:

-------------------------------------------------------------------
#!/usr/bin/perl

use strict;
use lib '/www/ocms/lib';
use Template;
use Template::Constants qw( :debug );

my $data = {
        '1213.103' => {
                name => 'Sally',
                age  => 21
        },
        '1502.523' => {
                name => 'Tommy',
                age  => 25
        },
        '.109'     => {
                name => 'Kevin',
                age  => 54
        }
};

my $tt = Template->new or die Template->error;

$tt->process( \*DATA, { data => $data } ) or die $tt->error;

__DATA__
[% USE Dumper %]

[% Dumper.dump( data ) %]
[% FOREACH id = data.keys.sort %]
[%      id %]
[%      Dumper.dump( data.$id ) %]
[% END %]
-------------------------------------------------------------------

When id is '.109', data.$id returns nothing.  I was thinking that
maybe a patch to Stash's get() could solve the problem, by first
doing a check to see if they $ident value would return something on
its own, before splitting it and recursing down the dot-separated
parts.  But I had trouble making that work.  Like I said, this may
well be a feature, but it seems strange to me that hash keys with a
non-leading dot work fine; it's only the dot-leading keys that fail
when used in this way.

Any thoughts on how (or whether) to approach a fix?

Thanks,

Dave

/L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\
Dave Cash                              Power to the People!
Frolicking in Fields of Garlic               Right On-Line!
[EMAIL PROTECTED]                                  Dig it all.

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to