Skip Menu |

This queue is for tickets about the Math-Prime-Util CPAN distribution.

Maintainer(s)' notes

The latest version is in https://github.com/danaj/Math-Prime-Util

    git clone --origin upstream git://github.com/danaj/Math-Prime-Util.git Math-Prime-Util

Comments, issues, and patches are welcome at either RT or github, or send me email.

Report information
The Basics
Id: 87834
Status: rejected
Worked: 30 min
Priority: 0/
Queue: Math-Prime-Util

People
Owner: DANAJ [...] cpan.org
Requestors: jimm [...] renewalcomputerservices.com
Cc:
AdminCc:

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



Subject: examples don't work, Math::Prime::Util doesn't work, errors calling functions
Date: Tue, 13 Aug 2013 15:33:50 -0700
To: bug-Math-Prime-Util [...] rt.cpan.org
From: Renewal Computer Services <jimm [...] renewalcomputerservices.com>
Math::Prime::Util v0.3.1 perl 5.16.3 multithreaded, strawberry perl x64 stable executing the attached code tp.pl 10000 500 this line gives an error but should not. my $aref = primes($lower_bound, $upper_bound); #v0.3.1 this gives error Undefined subroutine &main::primes called at D:\prj\twin-primes\tp.pl line 67. my $aref = Math::Prime::Util->primes($lower_bound, $upper_bound); #v0.3.1 this gives error too many parameters to primes at D:\prj\twin-primes\tp.pl line 68. my $aref = Math::Prime::Util::primes($lower_bound, $upper_bound); #v0.3.1 this gives no error but returns empty list for 9500,10500 the latter simply prints -------------------- center=10000 offset=500 lower bound=9500 upper bound=10502 min difference= max difference= count=0 -------------------- which is invalid. Math::Prime::Util v0.3.1 this gives error Undefined subroutine &main::primes called at D:\prj\twin-primes\tp.pl line 67. I got this usage from the example for primes() from the CPAN documentation. I am using bigint. nothing I try works. -- Renewal Computer Services <http://RenewalComputerServices.com> Jim Michaels, Owner 1303 NE 87th Ave <http://www.mapquest.com/maps/1303+NE+87th+Ave+Vancouver+WA+98664-1959/> (87th Ave & 13th St), Vancouver, WA, 98664-1959 USA, 1-360-521-2060 Cell 1-10pm Serving Vancouver, WA DIY Computer Repair Info: Jesusnjim.com <http://Jesusnjim.com> jimm@RenewalComputerServices.com <mailto:jimm@RenewalComputerServices.com> jmichae3@yahoo.com <mailto:jmichae3@yahoo.com>

Message body is not shown because sender requested not to inline it.

Argh, this is basic "how to use modules in Perl" and arrays vs. array references stuff, that has nothing to do with Math::Prime::Util. You need to stop using the RT system as a way to debug your programs. On Tue Aug 13 18:34:06 2013, jimm@renewalcomputerservices.com wrote: Show quoted text
> Math::Prime::Util v0.3.1 > perl 5.16.3 multithreaded, strawberry perl x64 stable > > executing the attached code > tp.pl 10000 500 > this line gives an error but should not. > my $aref = primes($lower_bound, $upper_bound); #v0.3.1 this gives > error Undefined subroutine &main::primes called at > D:\prj\twin-primes\tp.pl line 67.
That's because the module doesn't export any functions by default. use Math::Prime::Util 'primes'; or use Math::Prime::Util qw/primes next_prime prime_count/; or use Math::Prime::Util ':all'; The latter says "I want you to clutter my namespace with every function you have." which sometimes is what you want. This is indicated in the first lines of the synopsis of the documentation. Show quoted text
> my $aref = Math::Prime::Util->primes($lower_bound, $upper_bound); > #v0.3.1 this gives error too many parameters to primes at > D:\prj\twin-primes\tp.pl line 68.
Using -> is a method call, which means it is handing in the class name as the first parameter. We're not making objects. Show quoted text
> #v0.3.1 this gives no error but returns empty list for 9500,10500 > my $aref = Math::Prime::Util::primes($lower_bound, $upper_bound);
This does not return an empty list. Add the line: print join(",", @$aref), "\n"; after the call to primes, and you can see that we have returned the primes requested. Replace the line: my $num_primes_found = $#aref + 1; with my $num_primes_found = $#$aref + 1; and watch your program work. You may find things easier if you just do: my @prime_array = @{primes($lower, $upper)}; and then you can use standard array referencing.
Closing again. I don't see the issue with this module -- it is working as documented. The issues brought up are with how to use modules, arrays vs. array references, and with bigint.