Logo

Programming-Idioms

History of Idiom 22 > diff from v2 to v3

Edit summary for version 3 by :

Version 2

2015-05-06, 21:04:49

Version 3

2015-07-31, 19:00:48

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Code
print "Perl automatically converts numbers, like ", 7, "to strings when needed\n";

my $foo = "12" + 13;   # Foo is now 25
Comments bubble
Perl automatically converts numbers to strings and strings to numbers whenever required.