I think there are some problems with your code.
First, a number of typos, so it won't compile.
Second, if $tagnumber is a repeatable field you will only fix the first one.
You would have to do something like this instead:
my @existing_fields = $record->field($tagnumber);
And then loop through the resulting list of fields.

But, as there is no updating function just for subfields, it is tempting to fall back 
upon "bad programming behavior" and simply do something along the lines of

use MARC::Batch;
use strict;

my $batch = new MARC::Batch( 'USMARC', 'my.mrc' );
$batch->strict_off;
while ( my $marc = $batch->next() ) {
    for my $field ($marc->fields()) {
        next if int($field->tag()) <= 10;
        $field->{_subfields}[-1] =~ s/\s+$//g;
    }
    print $marc->as_usmarc();
}

But you wouldn't do that, would you? ;-)

Leif

Reply via email to