This tutorial was made on Os x. But the process should be similar if not identical on any UNIX based operating system. Just substitute the cmd button for the ctrl button.



Start by opening a new terminal window

Applications>Utilities>terminal.app

Then change your directory to the desktop

cd Desktop

Now create a new file using the nano command in the terminal. Nano is a terminal based text editor.

nano filename.plx

Your terminal window should now look similar to this



When starting a new perl document always start with the following.

#!/usr/bin/perl

This lets the terminal know which runtime environment to use. Now, let's start by making a hellrld application. Type the following code into the terminal.

print "Hello World! \n";

The print command is what tells the environment to display text.

Notice the quotation marks. You can use either single or double quotation marks. Double quotation marks allow you to use code such as \n within the quotation. If you use single quotation marks any code within the quotation marks will not be seen as code. It will be seen as plain text.

Notice how at the end I put /n. /n is a command that tells the environment to create a new line. If we did not include this than a new line would not be printed and the bash prompt will appear directly after the printed text.

Now that we have our code written and understand what each part of the code is doing we need to save it. This can be done by pressing "^o" or ctrl and "o" at the same time and pressing the enter button. This will save the file to the desktop or what ever directory you are in.

Now you'll want to open up a new terminal tab. This can be done by going to the shell menu and clicking new tab or holding cmd and "t" at the same time.

Change your directory to the desktop again.

cd Desktop

Now you'll want to chmod the file so that it is an executable.

chmod +x file.plx

chmod stands for "Change mode". And the "+x" changes the file to an executable.

Now you'll want to open the file. This can be done via the following command.

perl file.plx

or

./file.plx

You can use either of those commands to open the file. The perl command will open the file even if you didn't chmod it to an executable. However, the ./ command will only work if the file is an executable.

If you did everything correct you should get this.



If you have any questions feel free to ask .