tt2 ref checking

CrashKat crashkat at cmetech.com.au
Tue Feb 24 22:24:21 CST 2004


Hi Melbourne PM,

I'm getting a bit of a headache the following problem. Hope someone can
help.

Template toolkit, in most instances, will treat a scalar as an
arrayref of 1 element, if you treat it as an array. 

This doesn't work, however, if your scalar value is 0.

Is there any way of checking if a variable contains a reference?
What I want to be able to do is something like this:

unless(ref($array) eq 'ARRAY'){
	$array = [$array];
}

...but in a template. Or maybe there's a much better way?

Thanks
crash

-- 
Please do not send me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html




More information about the Melbourne-pm mailing list