Logo

Programming-Idioms

History of Idiom 22 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-01, 16:38:37

Version 5

2015-08-01, 16:39:13

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
Code
print "Perl automatically converts numbers, like ", 7, "to strings when needed\n";

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