I am inclined to concur with
Anonymous Monk's
answer, however, (s)he hid the most important point after the "readmore" tag. So the real question is: Did you put your script onto a web server, or did you try to open it just like you opened it with your editor? If the latter, then you should read
Re: To call a .pl file when a button is pressed on a GUI created using Perl CGI (webserver) (as mentioned in Anonymonk's post)