in reply to Will this work?

First thing you'll want to do is change
#!/usr/local/bin/perl
to
#!/usr/local/bin/perl -T -- use strict; use warnings; use CGI();
Then you should forget about your program for a while and do some reading. The following reading list covers everything currently present in your program (you need strictures, you need lexical variables, and you need CGI, and there are alternatives to double quotes). Eventually you'll want to read the following also