Also you can use TextEdit.
At the top of your file type:
"#!/usr/bin/perl" w/o quotes
When you're done coding, open Terminal. cd into the correct directory. Then type "chmod +x _____" w/o quotes where _____ is your file name. Then type "./______" w/o quotes where _____ is your file name. BOOM!