[Templates] Fun with arrays
Randal L. Schwartz
merlyn@stonehenge.com
Sat, 10 Feb 2007 02:43:10 -0800
>>>>> "Mihai" == Mihai Bazon <mihai@bazon.net> writes:
Mihai> After some hassling I understood that returning an empty array from a function
Mihai> is equivalent to returning undef, which TT interprets as an empty string (and
Mihai> empty_string.size == 1 because.. err... that's written in the manual but it
Mihai> doesn't make too much sense so I forgot why).
If I recall, you can return an arrayref, which will always be interpreteed
correctly as an "array" in TT-side. So, returning [] will correctly
be seen as "size of 0" and [42] will be seen as "size of 1", etc.
TT was never intended to call arbitrary methods or functions... the callback
scheme has a particular protocol that must be followed.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!