Skip Menu |

This queue is for tickets about the OAI-Harvester CPAN distribution.

Report information
The Basics
Id: 43944
Status: resolved
Priority: 0/
Queue: OAI-Harvester

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

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



Subject: Net::OAI::Record::OAI_DC::asString bug
Date: Sun, 8 Mar 2009 10:34:43 -0700 (Pacific Daylight Time)
To: bug-OAI-Harvester [...] rt.cpan.org
From: Batman <batman900 [...] gmail.com>
Hi, in Net::OAI::Record::OAI_DC the asString method is wrong, instead of building a string it prints the contents. A fix is shown below: sub asString { my $self = shift; my $r = ''; foreach my $element ( @OAI_DC_ELEMENTS ) { foreach ( @{ $self->{ $element } } ) { $r .= "$element => $_\n"; } } return $r; } Cheers!! Matt Spear batman900@gmail.com
On Sun Mar 08 13:34:14 2009, batman900@gmail.com wrote: Show quoted text
> Hi, in Net::OAI::Record::OAI_DC the asString method is wrong, instead > of building a string it prints the contents. A fix is shown below: > > sub asString { > my $self = shift; > my $r = ''; > foreach my $element ( @OAI_DC_ELEMENTS ) { > foreach ( @{ $self->{ $element } } ) { > $r .= "$element => $_\n"; > } > } > return $r; > }
"print"ing the record is plain wrong, agreed. What about (should be more efficient): sub asString { my $self = shift; my @r; foreach my $element ( @OAI_DC_ELEMENTS ) { foreach ( @{ $self->{ $element } } ) { push(@r, "$element => $_"); } } return join ("\n", @r); } This will lack the trailing "\n" and might be of favor when inserting the result somewhere.
fixed in 1.14a as outlined in my past reply. I'm still uneasy about the "\n" inserted but alternatively returning them under inspection of wantarray as list probably would break some existent code (my impression is that the typical "print $rec->asString()" might have accidentially worked)