Perl doesn't differentiate variables by types, only by contexts.
If a scalar-context variable holds something that can be interpreted as a number, perl will do so automatically at need. ______________________________________________________________________
TANSTAAFL!
## Use as a string - add together
$yetAnother = $yetAnother." ".$myVariable;
## The value of $yetAnother is now "Hello World 27822"
## Now lets use it as a number
$myVariable = $myVariable + $anotherVariable;
## The value of $myVariable is now 27845
So long as the variable only contains numbers (and a period in the case of floating point fractions) it can be treated just like a number! One of the beauties of Perl!!!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.