I was wondering why it's always a quiz to figure out whether a value is 
empty or not. let's say I've

$var = {
   array => [],
   hash  => {},
};

in perl I can say

do {...} if @{ $var{array} };
do {...} if %{ $var{hash} };

in template toolkit, passing $var to the template (var=>$var), this 
won't DWIM:

  IF var.array;
    INCLUDE process_array;
  END;

or

  IF var.hash;
    INCLUDE process_hash;
  END;

it will always call the INCLUDE, no matter if there is somethins in 
array/hash or not.

so in case of array I must always remember to use:

  IF var.array.size;

and in case of hash, I don't even remember what was the trick, I think

  IF var.hash.keys.size;

or checking on one of the keys.

When you code the template you still think perl and I always get burned 
on these subtle bugs when I rely on 'IF var.array' to DWIM :(

Any special reasons for this behavior?


_____________________________________________________________________
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/



Reply via email to