Free Perl Tutorials

How to test a perl programming file

Testing a programming file on your computer is not hard at all using the DOS prompt. In this example, we'll make a simple perl file, save it to our hard drive, and then test it. The best part is you don't need to download any programs in order to do it (well, unless you don't have PERL already installed, in which case you can go to Perl.com's download page to download the PERL programming language. I am using ActivePerl, which is an easy to install and add modules to perl administration program.

Creating a perl file. (Perl saves all its files as the file extention ".pl")

1) Go to Start->Accessories->Notepad
2) Cut and paste, or type the following code:
print "HELLO YOU SCHUCK!";

3) I recommend creating a folder on your C: drive called "test".
4) Save the notepad file name as "t.pl", and set the save as type to "All Files".
5) Now we will call the perl file from your command prompt
6) Go to Start->Run
7) Where it says open, type "cmd" to open your command prompt.
8) It will pull up a new, all black window with the text: "C:\Documents and Settings\Your Current Computer User>"
9) We need to navigate to our directory with the program we want to run, so type in "cd\". It stands for change directory, and the "\" sends it back to the drive.
10) Your prompt should now read "C:\>". If you wanted to change drives, you can do so here by typing "D:", to change to the D drive or "E:" to change to the E drive and so on.
11) So now, we will use the cd function to go to the folder we want to on our c drive. So next to C:\> type "cd test" and hit enter, you'll notice it changes your prompt to "C:\test>"
12) Now all we have to do is type the file name we want to run after "C:\test>" and it will run the file, so type "t.pl".
13) You should see HELLO YOU SCHMUCK! just below your command line!

That's all there is to it, so testing any programing you would like to via your command prompt is just that easy! Good luck programming!