in reply to create link from my image

What is the HTML you want to create?

What HTML does your current code create?

Have you looked at the CGI.pm documentation and looked for "href"?

Personally, I find it easier to just print the HTML I want, potentially using one of the Template systems.