sub atoi { my $t; foreach my $d (split(//, shift())) { $t = $t * 10 + $d; } } $number = atoi("123");