Sunday, November 21, 2010

PERL – Cont.

Scalar Variables:

* To store a piece of scalar data, use scalar variables.

* Starts with a “$” sign followed by alphanumeric or underscores. Eg: $i, $length, $interest_compound_yearly, etc.

Rules for using a variable:

· Variable name should start with a letter or underscore after $. No other character or numbers should be used.

· After first character, variables can contain any other letters, number or underscores.

· Case sensitive. i.e., $var is different from $VAR and $Var.

· Not longer than 255 characters.

· To assign a variable use a assignment operator. Most commonly “=”. Eg: $i = 1;

Constructing Perl Scripts:

§ Consists of one or more statements, in executed order.

§ Can be simple statements, such as variable assignment or the expressions.

§ It doesn’t care about white spaces beyond the semicolon.

§ Entire Perl script of multiple statements can be written in one single line.

§ Perl can also contain expressions. i.e. which results in a value.

No comments:

Post a Comment