|
|
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
my($age) = 30; my($weight) = 200; my($name) = "John Smith"; print "$name is $age old and weighs $weight\n";
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";
|
|