I am trying to do some simple regular expressions but just can't get them right.
I have a very long number that I am trying to perform some reg ex funtions on. When I put the long number in quotes, the reg ex works fine. When I do ot use quotes, the number is viewed as numeric and the reg ex pulls out the scientific notation.
These are numbers and not strings. How do I use the reg ex and get the proper numeric information? I am familiar with Math::BigFloat but have not found a solution to my problem within that module.
It seems like a simpler question would be; how do I tell Perl to not convert my long numbers to scientific notation?
BTW I am using Active State v5.8.7 on Windows XP.
Following are code/output samples.
Example 1:
## Grab the last three digits after decimal\n";
$m = "7191750529163469.123"; # notice the double quotes, this is now a string
print "$m\n";
$m =~ /(\d\d\d)$/; #Get the last three digits.
print "$1\n";
$m = "7191750529163469.123"; # notice the double quotes, this is now a string
print "$m\n";
$m =~ /(\d\d\d)$/; #Get the last three digits.
print "$1\n";
Output:
7191750529163469.123
123 (this is what I wanted the reg ex to pull out)
123 (this is what I wanted the reg ex to pull out)
Example 2:
## Grab the last three digits after decimal\n";
$m = 7191750529163469.123; # notice NO double quotes, this is still a number
print "$m\n";
$m =~ /(\d\d\d)$/; #Get the last three digits.
print "$1\n";
print "$m\n";
$m =~ /(\d\d\d)$/; #Get the last three digits.
print "$1\n";
Output:
7.19175052916347e+015
015 (this is NOT what I wanted the reg ex to pull out)
015 (this is NOT what I wanted the reg ex to pull out)
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
