Well, I'm currently learning Perl too, so it might not be up to par with other Perl guides. The basics of Perl! Chapters: Chapter 1: Starting off Chapter 2: Your first Perl program Chapter 3: Numbers + Strings Chapter 4: Variables More coming soon. Chapter 1: Alright, now you might be asking "what excatly is Perl?". Well since I can't be annoyed typing up something fancy and accurate, I'll get it from Wiki or something. http://en.wikipedia.org/wiki/Perl Now we'll need to download Perl, which can be found here. *Note you'll need Winrar to open it. Alright now that everything is downloaded and set up, you might be wondering how to run a script. Well I'll tell you how! Code: Go to Run>type in CMD and hit enter> type in "c:/perl/bin/scriptname.pl" Now that we have that squared away I'll show you how to make your first program. Chapter 2: Now to being open up notepad and at the top put: Code: #!/usr/bin/perl Now hit enter a few times and put in Code: print 'Hello world!'; now save it as 1.pl, and save it in C:\Perl\bin now run it, and if you're successful you should see Hello world! in your command promp. Great job! Now move on to the next chapter! Chapter 3: Now numbers in Perl aren't like regular numbers. Instead of having 5,000 or 5 000 in Perl you'll have to put it as 5000. Strings are lines of text either with single quotes or double. If the line is in double quotes it'll be read and you can put in commands in the quotes such as /n to put it on two different lines. If it's in single quotes it'll be read as just / and n nothing special. Chapter 4: Now we're on our way. There are 3 types of variables: Scalars Arrays Hashes Scalars: Scalars begin with the dollar sign: For example if I were to use a scalar I'd put: Code: my $r = 7; You can use different letters and words instead of "r". For example I could do this: Code: my $food = "Tomato"; my $drink = "Mountain Dew"; print "My favorite food and drink is $food and $drink; It'll show up as this: My favorite food and drink is Tomato and Mountain Dew Instead of print you may also use say. Print starts new lines automatically, and with say you have to add them manually. You can also do math problems with Scalars. The symbols are Of course you know what the first four symbols are, but what is the last one? Well what that does is combines the number, for example if I put 5 . 6 it would equal 56, pretty cool eh? Alright I'll wrap it up for now as I'm getting tired of typing :[ I'll edit it with more information over time.
Very basic. How do if, and for statments work? What are scalars? Define please. I think more examples would be nice, to explain what your trying to say. Like give an example with an explination for the single and double quotes and stuff. it makes learning so much easier.
Code: #!/usr/bin/perl Not really necessary unless you're programming on linux/unix or are planning to distribute there. Code: print "My favorite food and drink is $food and $drink; You didn't close the quote; you'll get an error. "." doesn't really "combine", more concatenating. In perl,if you use double quotes (") you don't have to concatenate variables, but if you were to use single quotes (') you would need to, or else: Code: print 'My favorite food and drink is $food and $drink'; Would return: Code: lol@lolx:~/Desktop$ perl wtf.pl My favorite food and drink is $food and $drink meaning you would need to do this: Code: print 'My favorite food and drink is '.$food.' and '.$drink; Pretty basic, but I believe it should help people get going with Perl on their first go.
Thanks CP, I knew I was forgetting some things in my examples, guess my head isn't screwed on tight. :\
Yep, you're welcome. If anyone has any questions about this tutorial post them here and I'll try to help the best I can.
As I am trying to learn more languages this will be helpful to me, is it possible for you to add some more? I have been looking at this guide and been doing it at the same time (Also using Cp's suggestions). So I now want to know what else this can be used for. Anyone?