Perl – How to convert a string to a number in Perl

floating-pointperlstring

I have a string which holds a decimal value in it and I need to convert that string into a floating point variable. So an example of the string I have is "5.45" and I want a floating point equivalent so I can add .1 to it. I have searched around the internet, but I only see how to convert a string to an integer.

Best Solution

You don't need to convert it at all:

% perl -e 'print "5.45" + 0.1;'
5.55