Perl Crash Course: Variables and Data Structures

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

In 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…

« Getting it installed on… | TOC | Scalars »

More To Explore

Documentation
vinny

bbPress Notify (No-Spam) Documentation

bbPress Notify (No-Spam) Documentation The bbPress Notify (No-Spam) is a free plugin that lets you control who gets notifications of new Topics and Replies in

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.