Monday, December 05, 2005

 

Perl: Scalars

Scalars are accessed by prefixing an identifier with '$'.
scalar:
A single value, either numeric or a character string.
identifier:
A "variable name." It is composed of upper or lower case letters, numbers,
and the underscore '_'. Identifiers are case sensitive (like all of perl).
Scalars are assigned to using '='

$scalar = expression;

--------------------------------------------------------------------------------

Example

...
################################################################
# Configuration parameters
################################################################
# this program's name
$progname = "mailform";

This is read as "the scalar progname is assigned the string mailform".
The '$' determines that progname is a scalar.
the '=' determines that this an assignment.
The double quotes (") define the string.
All statements end with a semi-colon ';'.


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?