Re: Question about MARC::RECORD usage
Bryan, Many thanks for the quick response. There are times when the proper order would be $a, $n, $p, $b, $c, as well, aren't there? Thanks for the forwarning - I haven't been told that yet - I'm not involved in the production of the data just in extracting it for publishing! This is proving to be something of a baptism by fire. 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 This look like something I can sit down this evening and work on to trya nd understand. Many thanks again - any other suggestions welcome.
Question about MARC::RECORD usage
I've been using MARC::Record for a while to extract data using Perl to prepare it for a publishing package (Ventura). This has all worked well for about a year until it was spotted that a repeated subfield has been omitted. 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. 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. All suggestions and approaches welcomed. Ed Brown www.go-britain.com www.solid-us.com 0870 752