Wednesday, March 9, 2011

Starting Perl Programming on Windows

We learn Perl Programming for "Systems Programming and Design" subject. Since most of the students are using Windows as the main operating system and use Linux operating systems installed as virtual PCs on windows, I thought of writing this post and show you how to install Perl on windows and start Perl programming.

All the major Linux operating systems are coming with Perl installed but on windows, you have to manually install Perl. First go to the Command Prompt and check whether your Windows operating system is already having a Perl installation. To check that type 'perl -version' or 'perl -v' and press Enter. If Perl is already installed it will show information about the installation. If not it will give an error message.

You can download Perl from http://www.activestate.com/ website.The size of the setup file will be around 25 MB so don't worry. Download the correct setup according to your Windows operating system.
After that install it. When you are installing it will ask you whether to update the PATH variable. Tick that and continue installation so that you don't need to update the PATH manually to run your Perl programs.
Once you have installed, go to Command Prompt and check whether it is installed correctly. Type 'perl -v' and you will get the information about the version. Now we have successfully installed Perl.

How to start Perl Programming ?

To write your Perl programs, you need a text editor. You can use the Notepad but my opinion is it is not good when you wish to do some serious programming because it doesn't highlight the syntax. I recommend 'Notepad++' which is a free software. You can download it from http://notepad-plus-plus.org/download . Download it and install.

Then create a new file in Notepad++ and before writing your program, save it with .pl extension. For the file type, select 'Perl Source File (.pl.....)'. Now type your first program and save it.

printf("Hello world ! \n");
printf("This is my first Perl Program \n");

Open the command prompt and change your current directory to the location where your Perl program is saved. Now type 
'perl filename.pl' and you will get the output as below.

Hello world !
This is my first Perl Program

P.S - From my next post I'll tell you how to master Perl Programming on your own.

-Tharindu Edirisinghe-
-SLIIT 10'-

3 comments:

I2MS said...

finaly i red ur post

Tharindu Edirisinghe said...

Thanks bro... Lets get 'A' for SPD

Anonymous said...

very helpful page. thank you very much!!!

Post a Comment