Skip Menu |

This queue is for tickets about the bignum CPAN distribution.

Report information
The Basics
Id: 57616
Status: resolved
Priority: 0/
Queue: bignum

People
Owner: Nobody in particular
Requestors: cmm7825 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Odd regex behavior with bignum
I'm using perl 5.10 on fedora 12, the latest version in the repos. I was creating a perl script to complete problem 16 of project euler, basically I have to go through each digit of a bignum and sum it up. Below is the code I came up with... #!/usr/bin/perl use bignum; my $num = 2**1000; my $sum = 0; while ($num =~ m/(\d{1})/g){ $sum += int($1);} print "$sum"; This doesn't work beacause the first few digits of the regex match are strange or incorrect characters. Eventually this solution worked: #!/usr/bin/perl use bignum; my $num = 2**1000; my $sum = 0; print "$num\n"; while ($num =~ m/(\d{1})/g){ print $1; $sum += int($1);} print "$sum"; I had to have those print statements in that order to work...even if I got rid of the new line after $num it wouldnt work. Or if I got rid of print $1 it wouldnt work. The strangest part is if I had a \n symbol before $sum the regex wouldnt work, even though it was after the matching loop. I know this seems bizarre but this is the only way I could get it to work.
I have tried this with various versions of bignum and Math::BigInt, including those shipped with Perl 5.10, but I can not reproduce this. Could you please confirm that this is still a problem?
Unable to reproduce.
Unable to reproduce.