Post by Gamoc on Jul 20, 2007 1:06:03 GMT -5
Now, PERl is a painful language to get started on. It isn't learning it, it's making it to where you can use it. You can't really start a PERL script unless you have a PERL interpreter installed onto your computer/server.
Now, you can either write your own interpreter, or get a pre-written one from Activestate. Now, I really suggest using the activestate interpreter. It has everything ready for you, all of the hard stuff is done for you.
Now, usually, once you have the interpreter installed, you start the script going by where it is. I will be using the common, linux used perl start. It is used on most linux machines. It looks like this.
#!usr/bin/perl
Now, the #! part has to be used to notify the server and browser that you are starting it.
Now, on a windows machine, it is commonly found that this one is used.
#!perl/bin/perl
I will be using the linux one in my examples.
Now, let me show you how to start it.
What a difference from what I showed you before.
Now, there is no closing it, it closes once the script ends.
Now, to write text out onto a page. You would use the following syntax.
Print "text";
Now, to see that with some real text.
Now, you are probably wandering what the /n was for. Well, it is a regular expression that will make a new line. Now, with that, you HAVE to surround the text in quotes. Double or single. There is a difference for each one, but we will save that for later in the tutorial when we get to variables. If you are putting an integer in a variable, then you would not surround it in quotes.
Well, that was easy. Now, sometimes, you have an error in your script. You will be wandering why the script just stops and no longer working. You have no idea where the bug is. You can put a warning in your header line.
It would look like this.
Now, can you see the error. The interpreter would tell you exactly where the error is and everything.
I will be using this in my examples from now on.
Now, let me tell you how to make comments in a PERL script. You use the # sign. It's very simple, just look.
# This is a comment
It would look like this in a code.
Now that we have that down, let's try using variables. Variables are storage areas. The store information for later use. Now, variable usage is exactly the same as PHP, the only difference is that in a more advanced tutorial, you can do more things with them.
Now, the syntax for a variable is this.
$variable = "variable value";
Now, you always need to remember that you can not use a functions name for a variable, such as for, or if. I will have to tell you about those some other time, though.
Let me tell you something else about variables in PERL. If you enclose them in double quotes (" ") in a function, the variable will use it's value, but if you put it in single quotes (' '), I have been told that the variable will not change to it's value, it will just put what you placed.
Now, let's try using a variable in a code to see if you can get it.
Now that would output some text onto the screen. Isn't that simple.
Now that you have started learning PERL, you are ready to embark on your PERL adventure. I hope that you have a great time learning PERL.
Now, you can either write your own interpreter, or get a pre-written one from Activestate. Now, I really suggest using the activestate interpreter. It has everything ready for you, all of the hard stuff is done for you.
Now, usually, once you have the interpreter installed, you start the script going by where it is. I will be using the common, linux used perl start. It is used on most linux machines. It looks like this.
#!usr/bin/perl
Now, the #! part has to be used to notify the server and browser that you are starting it.
Now, on a windows machine, it is commonly found that this one is used.
#!perl/bin/perl
I will be using the linux one in my examples.
Now, let me show you how to start it.
#!usr/bin/perl
What a difference from what I showed you before.
Now, there is no closing it, it closes once the script ends.
Now, to write text out onto a page. You would use the following syntax.
Print "text";
Now, to see that with some real text.
#!usr/bin/perl
Print "Hello, World!/n";
Now, you are probably wandering what the /n was for. Well, it is a regular expression that will make a new line. Now, with that, you HAVE to surround the text in quotes. Double or single. There is a difference for each one, but we will save that for later in the tutorial when we get to variables. If you are putting an integer in a variable, then you would not surround it in quotes.
Well, that was easy. Now, sometimes, you have an error in your script. You will be wandering why the script just stops and no longer working. You have no idea where the bug is. You can put a warning in your header line.
It would look like this.
#!usr/bin/perl -w
Prnit "Hello, World!/n";
Now, can you see the error. The interpreter would tell you exactly where the error is and everything.
I will be using this in my examples from now on.
Now, let me tell you how to make comments in a PERL script. You use the # sign. It's very simple, just look.
# This is a comment
It would look like this in a code.
#!usr/bin/perl -w
# This is a comment
# Some code
Now that we have that down, let's try using variables. Variables are storage areas. The store information for later use. Now, variable usage is exactly the same as PHP, the only difference is that in a more advanced tutorial, you can do more things with them.
Now, the syntax for a variable is this.
$variable = "variable value";
Now, you always need to remember that you can not use a functions name for a variable, such as for, or if. I will have to tell you about those some other time, though.
Let me tell you something else about variables in PERL. If you enclose them in double quotes (" ") in a function, the variable will use it's value, but if you put it in single quotes (' '), I have been told that the variable will not change to it's value, it will just put what you placed.
Now, let's try using a variable in a code to see if you can get it.
#!usr/bin/perl -w
$some_text = "some text";
Print "$some text";
Now that would output some text onto the screen. Isn't that simple.
Now that you have started learning PERL, you are ready to embark on your PERL adventure. I hope that you have a great time learning PERL.