View Single Post
Old 11-20-2003, 10:04 PM   #2 (permalink)
juanvaldes
Banned
 
Location: shittown, CA
This lesson will cover the basic perl data type and how to print to the console. This basic unit is called a Scalar variable and it can hold integers(1, 2, 3, 4, ...), floats (3.1549...), characters(a, b, c, etc...) and strings("bob is a good dog."). Scalars are a very versitile datatype that will be commonly used.

Also of note is that perl like many other common languages uses a semi-colon ( ; ) to signal the end of the line. Missing semi-colons is the cause of untold bugs so if something at first does not work check to see if you forgot that little guy.

Code:
#!/usr/bin/perl
$myFirstVariable;
# this is a empty variable it contains no data.
$myFirstVariable = "Hello World!";
# I have assigned the string "Hello World!" to the variable.
# You can also assign a value when you declare the variable like this $foo = "bar";
print $myFirstVariable . "\n";
# This outputs the string that is inside the $myFirstVariable out to the screen. 
# After the variable is a period this is the concatenation operator and it glues 
# the piece on the left with the part on the right, in this case "Hello World!" and "\n". 
# Lastly "\n" is the newline escape sequence.
juanvaldes is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76