Scalar Variables and Operators
Converting between numbers and strings
- When an arithmetic operator appears, Perl automatically converts
all arguments to decimal floating point values.
- Leading whitespace is ignored.
- Trailing non-numeric characters are ignored.
- Example: 123.456yadda would be interpreted as 123.456
- If the first non whitespace character is not a numeric, the
number is interpreted as zero.
- Numbers that appear with string operators become the ASCII
representation of the number.
- Example: 23 . 45 would be interpreted as the
string "2345".
- As a general rule, these conversions will just about always do
what you need and what you expect. Just make sure you are using the
right operators (numeric versus string).
Back to Syllabus
Previous: Operator Precedence and
Associativity
Next: Scalar Variables