|
|||||
Perl Crash Course: Variables and Data StructuresIn this chapter, we will see the three types of variables available in Perl: Scalars, Arrays, and Hashes. We will also work with lists, slices, and Complex Data Structures. However, before we go on, you will need to know a few basic commands so you understand the examples. Code comments: In Perl, you can add comments to the code by using the character #. Whatever is to the right of a # will not be parsed (with at least one exception: the $#array structure which we will see later in the Arrays section). You may find it annoying to not have /* */ structure for multi-line comments, but you'll be happy to know that you can emulate multi-line comments using POD, which we'll see later on. Printing: Perl prints to the screen through the command print, which takes a list of parameters as input. Assigning: To assign values to a variable, use = (the equals operator). Statement separator: Every statement in Perl ends with ; (semi-colon). Failure to end a statement with ; will result in a syntax error when trying to run your script. Math: Mathematical operators are +, -, *, /, and %, for addition, subtraction, multiplication, division, and modulus - respectively. The modulus operator returns the remainder of a division. Now on to the scalars... |
|||||
|
Copyright © 2010 use strict ;#) - All Rights Reserved |
|||||