in reply to debug the error!!

Kind of hard to read your code ;) but I think a ; is missing after
$calfilename=&gencalfn($corresonedname,$comparison)
but it's hard to tell. Try the code tags as le suggests.

/brother t0mas