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
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1057
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-26528-1442240610-1678.57616-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 192
Download (untitled) / with headers
text/plain 192b
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?
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-20774-1539008762-964.57616-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 20
Unable to reproduce.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2504-1539008812-1939.57616-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 20
Unable to reproduce.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.