Logo

Programming-Idioms

History of Idiom 22 > diff from v26 to v27

Edit summary for version 27 by :
[Perl] Comments: out of code block

Version 26

2015-12-30, 21:21:35

Version 27

2015-12-30, 21:24:31

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 $s = "12";
my $i = $s + 13;   # Foo is now 25
Code
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.