Perl CGI Happy Path: Creating Variables
Prepared by Bill Kilgallon,
Bill@KilgallonFamily.com
Creating variables
- Constants (literals) are certainly important, but if that's all
there was Perl would be a pretty boring place... nothing could ever
change.
- Up to this point we have been looking only at Literals
. Certainly important, but of limited utility for a dynamic
program, as a literal can never change.
- A Perl Variable, like variables in other languages, is
simply a symbolic representation of a storage location to be
manipulated.
- That's the fancy way to say it. You can also think of a variable
as a shoebox. You write a label on the side of the shoebox so you can
tell that particular shoebox from all the other shoeboxes you may be
using, and you can put a value into a shoebox to store safely for
later use.
- Perl scalar variables begin with a $ symbol,
followed with a letter, followed by more letters, digits, or
underscores. Variable names are case sensitive.
- Example Perl Scalar Names
Remember Perl does not care if it is a numeric scalar, or a
string scalar. This is very unusual compared to other
languages, and it is remarkable how few problems it creates, and how
many problems it solves. This is the kind of language your computer
science professors warned you about...
Return to Index