Perl Built-In Variables

   



Perl Scalar Variables

A scalar variable in Perl is a variable whose value can be an integer, a floating point number, or a string. Listing C.1 contains a simple example of printing the values of one integer-valued scalar variable and two string-valued scalar variables.

Listing C.1 simple1.pl

start example
my($age)  = 30; my($weight) = 200; my($name)  = "John Smith"; print "$name is $age old and weighs $weight\n";
end example

Remarks

After you include the path to the Perl executable in your PATH variable, you can launch the Perl script simple1.pl in Listing C.1 from the command line as follows,

perl -w simple1.pl

and the output is as follows:

John Smith is 30 years old and weighs 200

The '\n' in the print statement serves as a line feed in Unix (or line feed plus carriage return in Windows NT). You can also specify multiple line feeds such as:

print "abc\n\n\n";

You can also specify a 'tab' character like this:

print "indented\t\t";



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net