Problem with gmatch

I am using this script to clean up some stuff:

proc deleteTloc()
{
$sceneList = ls -tr;
for ($i=0; $i < size $sceneList; $i++ )
{
if (gmatch $sceneList[$i] "*\_Tloc")
{
delete $sceneList[$i];
}
}
}

but I get this error:

// Error: line 175: Invalid call to "gmatch". Check number and types of arguments expected by the procedure. //

I'm stuck. Everything I have read says this should work. So what's the trick?

the string functions are e bit picky about declaration types, so you should explicitly declare the variuables first.

proc deleteTloc()
{
string $sceneList[];
$sceneList = ls -tr;
for ($i=0; $i < size $sceneList; $i++ )
{
if (gmatch $sceneList[$i] "*\_Tloc")
{
delete $sceneList[$i];
}
}
}

man that is Awsome!!! What a bummer that the eroor message is so misleading.

Thanks!