On Fri, Nov 20, 2009 at 7:03 PM, Felipe Gasper (cPanel)
<[email protected]> wrote:
> How can I tell what kind of data a given variable is in TT? (Analogous
> to ref() in perl.)
>
> -F

I had the same question few months ago. See below the answer from Josh
Rosenbaum.

The thread was called: "detect the reference of a variable in TT"

----------------
One way is to use vmethods that are only associated with certain types.
ie: to detect a
*) hash use .keys and see if it returns a number.
*) scalar: length

You could roll your own ref vmethod or pass a routine via vars to do it.

This has been discussed before a few times on the list. It almost
should be in the main distribution even though I know the idea is to
keep knowledge of that type of thing away from the user. I certainly
wouldn't mind seeing it in the main distribution, though.

------- END ----------


Cyril Cheneson

I have to do some "real work" now, so don't write anything interesting. :-)
            --Larry Wall

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to