print "1 line of text" + 1;
will output the string "2". You start with a string and a number combined with the + operator. That operator takes two numbers as arguments, so perl attempts to convert the string to a number - this truncates from the first non-numeric character. We then evaluate 1+1 = 2. That two is then passed to the print subroutine, which takes a string input. Therefore, 2 is converted to "2" and output to STDOUT. Coming from a strongly-typed background, that still fills me with a profound warmth every time I do it.
In reply to Re^3: REGEX Match Single Digit
by kennethk
in thread REGEX Match Single Digit
by spickles
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |