I suspect you are writing this code on a Windows machine (using notepad for example) as this is a common issue since DOS/Windows text files are not the same as UNIX text files. Is this the case with you? I went over this with people in the past on this site about why this occurs and how to fix it.
DOS/Windows text file lines are terminated with a CR (Carriage Return) and an LF (Line Feed). Lines in UNIX text files are terminated with LF only. If you try to run a Perl script in UNIX and the first important line "#!/usr/bin/perl" is terminated with a CR/LF your program will spit out a "bad interpereter" message.
First of all, make sure your path to your perl interpereter is correct. Type "which perl". It should spit out "/usr/bin/perl", in which case your script has the right first line with the possible exception of the CR/LF. To tell if that is the case type this:
$ head -1 sample.pl | od -c
which should spit this out:
Notice the "\n" at the end. If it shows "\r \n" then it is a DOS/Windows file and you need to strip out the CRs. The best solution is not to use that nasty icky Windows to write your Perl code. But you can strip the CRs by:
$ tr -d '\r' < sample.pl > unixsample.pl
$ mv unixsample.pl sample.pl
$ chmod +x sample.pl
$ ./sample.pl
You may also have a utility called "dos2unix" installed on your system that does the same thing, or you can download that utility and install it. It's just a tiny utility which will strip the CRs from a file. With my example using the "tr" command you need to make sure the file you are redirecting to is a new file and don't use the same file name for both input and output, then of course you will have to set the executable bit on that new file before you run it and replace the original file with it. The dos2unix utility does all of this automatically.