I'm trying Perl's PDL in the following code:
#!/usr/bin/perl -w
use strict;
use PDL::Core qw(pdl);
use PDL::Math qw(isfinite);
use PDL::Primitive qw(statsover);
my $div = 4;
my @array1 = (0..10);
my $pdl_array = log(pdl(@array1)/$div);
$pdl_array->where(!isfinite($pdl_array)) .= 0;
my($mean,$stdev) = statsover($pdl_array);
die $pdl_array,"\n",$mean," ",$stdev,"\n";
and I'm getting this error:
Undefined subroutine &PDL::divide called at ./compare_const.pl line 10.
Any hint, please?Thanks a lot.
PDL has a minimum set of things that must be loaded. To get these all properly loaded, you must either
use PDL(which also exports a bunch of stuff) oruse PDL::Lite.(I for some reason thought you were explicitly calling PDL::divide directly and getting that error, hence my original answer below.)
Original answer:
I'm wondering why you think that should work?
Yes, PDL exports a bunch of stuff (if you use it, which you do not), but that doesn't give you any guarantee about where it is exporting it from. (In point of fact, it appears to export from a number of different places directly into the use`ing package.)
If you are trying to avoid namespace pollution, I would recommend either importing into a designated package and using stuff from there:
or using the OO interface (see PDL::Lite, I think?)