On Wednesday, May 03, 2006 9:28 AM, Ed @ Go Britain wrote: >In the 245 record it is >possible to have numerous $n and $p fields which need to be >output with formating between the fields. > >My knowledge of PERL isn't too good and I'm struggling to know >how to extract these repeated subfields and place formatting >between the subfields in the prescribed order $a, $b, $n, $p, >$c. Both n and p could be repeated several times.
There are times when the proper order would be $a, $n, $p, $b, $c, as well, aren't there? >At the moment I take each field into a variable eg > >$Field245c = $record->subfield('245','c'); > >and then output these as follows > > if ($Field245c) > { > $EntryBody = $EntryBody . " -- " . $Field245c; > } > >However, this approach assigns the first occurance of a >subfield and I haven't yet discovered a tachnique for >accessing further subfields. > According to the POD in MARC::Field: "Or if you think there might be more than one you can get all of them by calling in a list context: my @subfields = $field->subfield( 'a' );" Alternatively, get all subfields in the field and parse as needed: my $field245 = $record->field('245'); my @subfields = $field245->subfields(); while (my $subfield = pop(@subfields)) { my ($code, $data) = @$subfield; #do something with data #or add code and data to array unshift (@newsubfields, $code, $data); } # while ############### I hope this helps, Bryan Baldus [EMAIL PROTECTED] [EMAIL PROTECTED] http://home.inwave.com/eija