in reply to Perl Generating error on display.
your code works fine. The problem you may be coming across is your shebang line. It looks like you mixed linux with windows.
for a typical linux machine it would look similar to #!/usr/bin/perl. And for windows it would be the full path to the program.
What is the error that you are getting?