darren chamberlain wrote: > Stas Bekman <[EMAIL PROTECTED]> said something to this effect on 01/25/2002: > >>Andy Wardley wrote: >> >>>Perhaps the best solution is to have a '.size' method which works >>>consistently >>>across all data types: >>> >>> [% item.size %] # 1 >>> [% hash.size %] # scalar(keys %$hash) >>> [% list.size %] # scalar(@$list) >>> >>+1, not sure though what .size means for the scalar variable. >> > > How about: > > $Template::Stash::SCALAR_OPS->{ size } = $Template::Stash::SCALAR_OPS->{ length };
IMHO, this is not right. .size for hash and array will show the number of elements in the datastructure, a scalar always has exactly 1 element (or we probably can say 0 elements if it's undef). So I'd say: Template::Stash::SCALAR_OPS->{ size } = $Template::Stash::SCALAR_OPS->{ defined $_[0] ? 1 : 0 }; _____________________________________________________________________ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/