PERL Class Lesson 2
SCALAR SCRIPT
previous script, HELLO WORLD
lesson2 overview
next script, LEARNING BASIC MATHMATIC OPERATIONS
SCALAR SCRIPT
- In SSH shell type: vim scalar.pl
- Once in vim, create the following script
- Think of anything with my $ in front of it as a box
You have to label a box and then you can put something into it
you can label the box anything you want like bills or food and then put a string of words or numbers in it
my $bills = 'electricity'
my $food = 'bread'
If you want to put something new in the box you can put whatever you want to, BUT what was previously in there will have to come out
so lets say you do this
my $food = 'milk and cheese'
When you go to show what is in the boxes you will see 'electricity' and 'milk and cheese'
There won't be any 'bread' just the 'milk and cheese'
- Now you need to save it (wq scalar.pl)
- change permissions (chmod 755 scalar.pl)
- And run it (./scalar.pl)
Uh Oh!!! Here you see we have some errors
It is saying that it doesn't know what to do with the word number
It is also saying that it thinks it recognizes the word number but it is Bare without the $ dollar sign in front of it.
To get rid of these errors all we have to do is add $ in front of the word number
So open it again and fix the code (vim scalar.pl)
Now run it again to see if it is working properly (wq scalar.pl)
Ta DA!!!!! IT WORKS!!!!
Your HOMEWORK is to play with this and make up your own packages (boxes that start with my $) and have them print out what you put in them
Have fun!!!
==================================================
previous script, HELLO WORLD
lesson2 overview
next script, LEARNING BASIC MATHMATIC OPERATIONS