Testing if Perl is Working

Checking if Perl is working for the shell-deprived.

Perl is a very popular language and a common question I here from those that are new to open source web development in general is “Why isn’t my Perl script working?” or “How do I know if I have Perl installed/working?”.

There are lots of ways you can tell if you have Perl (or mod_perl, which is the Apache module enabling Perl on your web server) installed. If you have shell access it’s easy, but what about users who only have access to their host via FTP? Well, you could create a page that contains the phpInfo function, but sometimes it’s useful to actually see a Perl script being executed correctly. Simply copy and paste the code below into a file called test-perl.pl and upload it to your web host, use your CGI-BIN if required. Then set the file’s permissions to 755, which means executable (yes, you can do this using an FTP client). Then all you have to do is visit the file with your browser, eg. http://www.yoursite.com/cgi-bin/test-perl.pl.

#! /usr/bin/perl
print "Content-Type: text/htmlnn";
print "Perl is working!n";

With any luck, you’ll see the text “Perl is working!”