Edward Summers wrote:
On Apr 29, 2006, at 1:08 AM, Mark Jordan wrote:
Edward Summers wrote:
Deleting subfields is a bit tricky since subfields may repeat, and
sometimes people just want to delete one of them. An unfortunate
state of affairs perhaps.
Yeah, I can see what you're saying, but doesn't that also apply to
repeatable fields?
Well yeah it does, and you're right there is a
MARC::Record::delete_field isn't there. Would having something similar to
that in MARC::Field be useful to you?
Strangely enough, I've encountered two separate situations in the last
two weeks (both on Friday afternoons... I think I've fallen into some
kind of recursive metadata loop) where I wanted to delete just a
specific subfield. 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?
If a particular subfield that is one of a repeated set needed to be
deleted, it could be identified by a regex or by its order in an array
(following object syntax probably not correct):
@subfields = $subject->subfields();
foreach $notwanted (@subfields) {
if ($notwanted =~ /badsubject/) {
$notwanted->delete_subfield();
}
}
That could work if subfields were objects, but they're just strings. It
could simply delete all of them unless a second parameter is passed in,
which would basically act like a filter:
$field->delete_subfield('a', qr/badsubject/);
Yeah, I knew I had the syntax wrong. The revised one you supply looks
intuitive. Could the second parameter also accommodate the order (in an
array) of the target subfield if the subfield repeated, for when you
know your records are consistent enough to use it (such as when you get
vendor records that have two 856 u subfields but you only want the
second one)? For example:
$field->delete_subfield('a', 0);
Mark