Re: Seekign help with MARC.pm ->as_string

[email protected] (Bryan Baldus)
Newsgroups perl.perl4lib
Message-ID <a06110400c429bc1273a9@[74.134.222.82]>
(By MARC.pm, I believe you mean the MARC::Record distribution of modules).

At 6:09 PM -0700 4/14/08, Migell Acosta wrote:
>So, I need to do pattern matching, I think from the docs I'm 
>supposed to do it like this: if($phys_format->as_string() =~ 
>/Paperback/ ). I think I need the "as_string" in order to do regular 
>expressions, yes?
>
>However, what I get back from the interpreter is "Can't locate 
>object method 'as_string' via package Paperback (perhaps you forgot 
>to load Paperback)?"

According to the POD of MARC::Field, at "subfield(code)"

"When called in a scalar context returns the text from the first 
subfield matching the subfield code."

So, in  "my $phys_format   = $field->subfield('c');", $phys_format 
contains the text of subfield c, rather than a Perl object. Instead 
of:

if($phys_format->as_string() =~ /Paperback/ ){

(which, according to the error, is the same as saying 
"if(Paperback->as_string() =~ /Paperback/){")

This:

if($phys_format =~ /Paperback/ ){

should work.

The as_string method is used for entire MARC::Field objects (whole 
fields, with optional filtering to include only some of the 
subfields).

###################


I hope this helps,

Bryan Baldus
[email protected]
[email protected]
http://home.inwave.com/eija
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.