PERL Class Lesson 2
HELLO WORLD SCRIPT

previous script, first.pl              lesson2 overview              next script, scalar.pl



HELLO WORLD SCRIPT

- In SSH terminal type:  vim hello.pl  and hit Enter

- Once in vim, create the following script




In the last script (first script) we defined most of what is already in the hello world script. So we will stick to defining only that which is new.

There are two ways of telling the computer to print a string of words. (words that are strung together one after another like a sentence)

 1) double quote marks    "    
and
 2) single quote marks    '    

What is the difference you ask?

Well, things between  double quote marks  tell the computer that funtions are in the string of words so look for them and obey them.
Things between the  single quote marks  tell the computer to ignore anything that looks like a function and print out everything as it is typed in the single quote marks.

When we ran the last script, it output (printed) the word  words  butting it right up in front of the "location of the next command request (pwd) prompt'
That doesn't seem very practical.
So to get a carage return or move the curser to a new line (next line down) a function can be inserted into the string of words to tell it to move down when it is finished printing out the words
This command is   \n  

Let's see how this works shall we?
- Save the script (wq hello.pl)
- Change permissions (chmod 755 hello.pl)
- And run it to see what it does (./hello.pl)




We see that once te  Hello world!  was printed out it followed the newline command and moved the curser down to the next line.
Then  Hellow world\n  was printed out but the computer ignored the newline command treating it as if it was just a part of the string of words.
And the computer just butted the 'location of the next command request (pwd) prompt' right up behind it


Your HOMEWORK is to play with this and print out your own  string of words  (sentences) and use the  newline command 

Have fun!!!

==================================================

previous script, first.pl              lesson2 overview              next script, scalar.pl