in reply to SCALAR ref error help!

You might want to look into using Template-toolkit http://template-toolkit.org/ which allows you to separate your code and HTML