#!perl
# Fig. 26.4: variable.pl
# Program to illustrate the use of scalar variables.

$a = 5;
print "The value of variable a is: $a\n";

$a = $a + 5;
print "Variable a after adding 5 is: $a\n";

$a *= 2;
print "Variable a after multiplying by 2 is: $a\n";

# using an uninitialized variable in the context of a string
print "Using a variable before initializing: $var\n";

# using an uninitialized variable in a numeric context
$test = $num + 5;
print "Adding uninitialized variable \$num to 5 yields: $test.\n";

# using strings in numeric contexts
$str = "A string value";
$a = $a + $str;
print "Adding a string to an integer yields: $a\n";

$strnum = "15charactersand1";
$c = $a + $strnum;
print "Adding $a to string \"$strnum\" yields: $c\n";

########################################################################## 
# (C) Copyright 2001 by Deitel & Associates, Inc. and Prentice Hall.     #
# All Rights Reserved.                                                   #
#                                                                        #
# DISCLAIMER: The authors and publisher of this book have used their     #
# best efforts in preparing the book. These efforts include the          #
# development, research, and testing of the theories and programs        #
# to determine their effectiveness. The authors and publisher make       #
# no warranty of any kind, expressed or implied, with regard to these    #
# programs or to the documentation contained in these books. The authors #
# and publisher shall not be liable in any event for incidental or       #
# consequential damages in connection with, or arising out of, the       #
# furnishing, performance, or use of these programs.                     #
##########################################################################