How do I convert a string to a number?
Use this atoi function:
sub atoi {
my $t;
foreach my $d (split(//, shift())) {
$t = $t * 10 + $d;
}
return $t;
} $number = atoi("123");
Use this atoi function:
sub atoi {
my $t;
foreach my $d (split(//, shift())) {
$t = $t * 10 + $d;
}
return $t;
} $number = atoi("123");
沒有留言:
張貼留言