Re: Deleting a subfield using MARC::Record

[email protected] (Edward Summers)
Newsgroups perl.perl4lib
Message-ID <[email protected]>
On Apr 29, 2006, at 10:31 AM, Mark Jordan wrote:
>  Maybe other people should verify the usefulness of a delete  
> subfield function before anyone does anything about it, though.  
> Would a half dozen +1 votes from perl4libers validate its usefulness?

Yes it would...but to get the changes out on CPAN we'd all need to  
convince Mike O'Regan who holds the keys to MARC-Record on CPAN.  
Right now the version on CPAN is not the latest version that's  
available in CVS on SourceForge. I think Mike has some performance  
concerns about the Unicode handling code in v2.0, since MARC::Record  
is used in some of his time critical applications. Hopefully we can  
benchmark v1.38 and v2.0 sometime and get the latest code pushed out  
to CPAN if things look OK. Or if this is not an option there is  
always the possibility of creating a MARC::Record2 on CPAN. That  
would be kind of ugly for backwards compatibility though.

At any rate if you are open to using the latest/greatest code from  
SourceForge there is nothing stopping us from getting a  
delete_subfield method working.

> $field->delete_subfield('a', 0);

In the interests of flexibility how about using hash key/value pairs?  
Here's what I'm thinking:

# delete all subfield u
$field->delete_subfield(code => 'u');

# delete first two subfield u
$field->delete_subfield(code => 'u', count => 2);

# delete all subfield u that have 'zombo.com' in them
$field->delete_subfield(code => 'u', match = qr/zombo\.com/);

# delete only the first subfield u that has 'zombo.com' in it
$field->delete_subfield(code => 'u', match => qr/zombo\.com', count  
=> 1);

# delete any subfield with a value that matches 'zombo.com'
$field->delete_subfield(match => qr/zombo\.com/);

So effectively there is AND boolean logic between any options that  
are supplied. If this looks good I've got some code that does it and  
some tests committed in SourceForge for you to take a look at [1].  
I'm open to suggestions on renaming parameters, etc... Here are the  
basics for checking out the code if you haven't done it before.

	 cvs -d:pserver:[email protected]:/cvsroot/marcpm login

	 cvs -z3 -d:pserver:[email protected]:/cvsroot/marcpm co  
-P marc-record

//Ed

[1] http://sourceforge.net/cvs/?group_id=1254
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.