Interesting, slightly older Perl here and it does exactly what the OP indicates. Whether or not it accomplishes what he wants to accomplish is a different subject.
I am baffled that anything would autonomously constrain itself to integer arithmetic -- I think we need to see some code to really assess what is going on.
Update: As a complete side note, the version of Perl doesn't appear to cause a difference in the handling of the string interpretation. I suspect the difference between ww's results and mine are how we chose to display the values (either say vs. print, or command line vs. script file {perhaps the way the quotation mark characters are interpreted from the command line?} ):
#!/usr/bin/perl -w
use strict;
{
my $originalValue = 5;
my $modifiedValue = "$originalValue.00";
my $escapedValue = "$originalValue\.00";
print "\$originalvalue = '$originalValue'\n";
print "\$modifiedvalue = '$modifiedValue'\n";
print "\$escapedvalue = '$escapedValue'\n";
}
exit;
__END__
---------------[ Older Perl ]---------------
C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>perl -v
This is perl, v5.8.9 built for MSWin32-x64-multi-thread
(with 12 registered patches, see perl -V for more detail)
C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>forcefloat.pl
$originalvalue = '5'
$modifiedvalue = '5.00'
$escapedvalue = '5.00'
---------------[ Newer Perl ]---------------
C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x
+64-multi-thread
(with 1 registered patch, see perl -V for more detail)
C:\Steve\Dev\PerlMonks\P-2013-09-23@1207-ForceFloat>forcefloat.pl
$originalvalue = '5'
$modifiedvalue = '5.00'
$escapedvalue = '5.00'
|