06-29-2010, 01:20 PM
Getting Started With Perl
All tutorials will be using Perl 5
What is it?
Perl is a acronym that stands for Practical Extraction and Report Language. Its Practical because its easy to code certain things in it. Extraction it looks at files and pulls the important things out. It reports the data found in files it looks at. So thats why it stands for what it does.
Was Created by Larry Wal, whom was known in the Unix world. Basically Perl takes bits of data from other programming languages like C. I think its very versatile and simple to learn.
Getting to use it!
To use Perl, you wont need to download any expensive software. All you need is the Perl Interpreter. Actually most probably wont have to install anything. Like if your running a Linux distro you most likely already have Perl 5 installed. Also you will need a simple text editor, you already have one on your computer so use it!
Perl is Powerful
Perl was designed to be a superset of many fairly complex UNIX tools. Its also got all the features as a high level language. Almost everything you can do in C you can do in Perl. You can do simple top-to-bottom scripts in Perl. You can do object-oriented programming in Perl. Also you can do structured programming in Perl. You can do alot!
If this isnt good enough there there also are extensive archives of various tools and libraries know as modules. They perform various common tasks in Perl. In here you can find things like modules to do base interaction, encryption and networking plus more. This means instead of having to write a code to do something you can just check for it and use it.
Its Flexible
A motto of Perl is "There's more then one way to do it". Perl was designed in the way different kinds of programmers basically could just jump right into Perl and feel comfortable. Meaning instead of learning a whole new list of commands and their effects you can just use ones that you already know. This is because Perl has many things that all do the same thing, just do them a bit different.
Getting Started Programming in Perl
Ok to program in Perl you will need the interpreter which is free for download. You can download it from Perl.com. If you really need more help on this just say something and i will help you. Im sure all of you already have it installed based off the fact this is a community which uses mostly linux distro's
Hello World!
Cant create an introduction without a simple Hello World program now can you? Well i sure as hell can, it gets annoying seeing the same thing. So how about instead we do something a bit different. Same concept just different words. Im not a fan of trends so lets begin!
Open up your text editor,
Windows = Notepad
Mac = SimpleText
Linux = Text Editor
Copy this code into it
#!/usr/bin/perl/ -w
print "I am learning Perl\n";
Ok lets explain
The first line is where i had installed Perl, you will need to change this depending on where you installed it. (This is called the Shebang line) =)
Include this on every script you create.
The -w just is like an error reporting thing. Use this it comes in handy!
Ok after that you see the whole Print thing
This is just like you think, it prints the words onto the screen! Amazing right? Then you see the \n this just means new line. It skips to the next line.
Ok now onto saving and running it.
Save it as <File Name>.pl | So like perl.pl
To run it go into the CMD Propmt / Terminal and navigate to the scripts folder
then from here type
perl -w <FileName>.pl
That is all for now, next one i will just show 2-3 examples and explain them.
All tutorials will be using Perl 5
What is it?
Perl is a acronym that stands for Practical Extraction and Report Language. Its Practical because its easy to code certain things in it. Extraction it looks at files and pulls the important things out. It reports the data found in files it looks at. So thats why it stands for what it does.
Was Created by Larry Wal, whom was known in the Unix world. Basically Perl takes bits of data from other programming languages like C. I think its very versatile and simple to learn.
Getting to use it!
To use Perl, you wont need to download any expensive software. All you need is the Perl Interpreter. Actually most probably wont have to install anything. Like if your running a Linux distro you most likely already have Perl 5 installed. Also you will need a simple text editor, you already have one on your computer so use it!
Perl is Powerful
Perl was designed to be a superset of many fairly complex UNIX tools. Its also got all the features as a high level language. Almost everything you can do in C you can do in Perl. You can do simple top-to-bottom scripts in Perl. You can do object-oriented programming in Perl. Also you can do structured programming in Perl. You can do alot!
If this isnt good enough there there also are extensive archives of various tools and libraries know as modules. They perform various common tasks in Perl. In here you can find things like modules to do base interaction, encryption and networking plus more. This means instead of having to write a code to do something you can just check for it and use it.
Its Flexible
A motto of Perl is "There's more then one way to do it". Perl was designed in the way different kinds of programmers basically could just jump right into Perl and feel comfortable. Meaning instead of learning a whole new list of commands and their effects you can just use ones that you already know. This is because Perl has many things that all do the same thing, just do them a bit different.
Getting Started Programming in Perl
Ok to program in Perl you will need the interpreter which is free for download. You can download it from Perl.com. If you really need more help on this just say something and i will help you. Im sure all of you already have it installed based off the fact this is a community which uses mostly linux distro's
Hello World!
Cant create an introduction without a simple Hello World program now can you? Well i sure as hell can, it gets annoying seeing the same thing. So how about instead we do something a bit different. Same concept just different words. Im not a fan of trends so lets begin!
Open up your text editor,
Windows = Notepad
Mac = SimpleText
Linux = Text Editor
Copy this code into it
#!/usr/bin/perl/ -w
print "I am learning Perl\n";
Ok lets explain
The first line is where i had installed Perl, you will need to change this depending on where you installed it. (This is called the Shebang line) =)
Include this on every script you create.
The -w just is like an error reporting thing. Use this it comes in handy!
Ok after that you see the whole Print thing
This is just like you think, it prints the words onto the screen! Amazing right? Then you see the \n this just means new line. It skips to the next line.
Ok now onto saving and running it.
Save it as <File Name>.pl | So like perl.pl
To run it go into the CMD Propmt / Terminal and navigate to the scripts folder
then from here type
perl -w <FileName>.pl
That is all for now, next one i will just show 2-3 examples and explain them.