There's someone in this thread who would know more about the mechanics
behind NET::OAI::Harvester->new, but from what you've told us so far, it's
possible that that call is failing to return a harvester object for some
reason. This is consistent with perl telling you $harvester is undefined
later on in the script. Given that, it might help to note a typical Perl
idiom for initializations that might faii:
my $harvester = NET::OAI::Harvester->new([stuff]) or die "Can't initialize
The idea is that if ->new() returns nothing (undef, or any other value Perl
considers "falsey"), the "die" part will get executed, and that halts the
script and prints the message to the console. "$!" is idiomatic Perl for
"the last error message," although whether that will have anything useful
in it depends on how the method you're calling was written.
On Tue, Jan 14, 2014 at 3:01 PM, Eka Grguric <[log in to unmask]> wrote:
> I am a complete newbie to Perl (and to Code4Lib) and am trying to set up a
> harvester to get complete metadata records from oai-pmh repositories. My
> current approach is to use things already built as much as possible -
> specifically the Net::Oai::Harvester (
> The code I'm using is located in the synopsis and specific parts of it seem
> to work with some samples I've tried. For example, if I submit a request
> for a list of sets to the oai url for arXiv.org (http://arXiv.org/oai2) I
> get the correct list.
> The error I run into reads "can't call listRecords() on an undefined value
> in *filename* line *#*". listRecords() seems to have been an issue in past
> iterations but I'm not sure how to get around it.
> At the moment it looks like this:
> ## list all the records in a repository
> my $list = $harvester->listRecords(
> metadataPrefix = 'oai_dc'
> Any help (or Perl resources) would be appreciated!
> MLIS Candidate, UBC iSchool