How can I convert a string to a number in Perl?
This is a simple solution:
Example 1
my $var1 = "123abc";
print $var1 + 0;
Result
123
Example 2
my $var2 = "abc123";
print $var2 + 0;
Result
0
You don't need to convert it at all:
% perl -e 'print "5.45" + 0.1;'
5.55