{
    "content": [
        {
            "type": "text",
            "text": "# MARC::Record (perldoc)\n\n## NAME\n\nMARC::Record - Perl extension for handling MARC records\n\n## DESCRIPTION\n\nModule for handling MARC records as objects. The file-handling stuff is in MARC::File::*.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **DESCRIPTION**\n- **ERROR HANDLING**\n- **CONSTRUCTORS**\n- **COMMON FIELD RETRIEVAL METHODS** (2 subsections)\n- **DESIGN NOTES**\n- **RELATED MODULES**\n- **SEE ALSO**\n- **TODO**\n- **IDEAS**\n- **LICENSE**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MARC::Record",
        "section": "",
        "mode": "perldoc",
        "summary": "MARC::Record - Perl extension for handling MARC records",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "ERROR HANDLING",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "CONSTRUCTORS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "COMMON FIELD RETRIEVAL METHODS",
                "lines": 92,
                "subsections": [
                    {
                        "name": "delete_fields",
                        "lines": 18
                    },
                    {
                        "name": "encoding",
                        "lines": 72
                    }
                ]
            },
            {
                "name": "DESIGN NOTES",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "RELATED MODULES",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 17,
                "subsections": []
            },
            {
                "name": "TODO",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "IDEAS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 10,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MARC::Record - Perl extension for handling MARC records\n",
                "subsections": []
            },
            "VERSION": {
                "content": "Version 2.0.7\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Module for handling MARC records as objects. The file-handling stuff is in MARC::File::*.\n",
                "subsections": []
            },
            "ERROR HANDLING": {
                "content": "Any errors generated are stored in $MARC::Record::ERROR. Warnings are kept with the record and\naccessible in the \"warnings()\" method.\n",
                "subsections": []
            },
            "CONSTRUCTORS": {
                "content": "new()\nBase constructor for the class. It just returns a completely empty record. To get real data,\nyou'll need to populate it with fields, or use one of the MARC::File::* modules to read from a\nfile.\n\nnewfromusmarc( $marcblob [, \\&filterfunc($tagno,$tagdata)] )\nThis is a wrapper around \"MARC::File::USMARC::decode()\" for compatibility with older versions of\nMARC::Record.\n\nThe \"wantedfunc()\" is optional. See MARC::File::USMARC::decode for details.\n",
                "subsections": []
            },
            "COMMON FIELD RETRIEVAL METHODS": {
                "content": "Following are a number of convenience methods for commonly-retrieved data fields. Please note\nthat they each return strings, not MARC::Field objects. They return empty strings if the\nappropriate field or subfield is not found. This is as opposed to the \"field()\"/\"subfield()\"\nmethods which return \"undef\" if something's not found. My assumption is that these methods are\nused for quick & dirty reports and you don't want to mess around with noting if something is\nundef.\n\nAlso note that no punctuation cleanup is done. If the 245a is \"Programming Perl / \", then that's\nwhat you'll get back, rather than \"Programming Perl\".\n\ntitle()\nReturns the title from the 245 tag.\n\ntitleproper()\nReturns the title proper from the 245 tag, subfields a, n and p.\n\nauthor()\nReturns the author from the 100, 110 or 111 tag.\n\nedition()\nReturns the edition from the 250 tag, subfield a.\n\npublicationdate()\nReturns the publication date from the 260 tag, subfield c.\n\nFIELD & SUBFIELD ACCESS METHODS\nfields()\nReturns a list of all the fields in the record. The list contains a MARC::Field object for each\nfield in the record.\n\nfield( *tagspec(s)* )\nReturns a list of tags that match the field specifier, or an empty list if nothing matched. In\nscalar context, returns the first matching tag, or undef if nothing matched.\n\nThe field specifier can be a simple number (i.e. \"245\"), or use the \".\" notation of wildcarding\n(i.e. subject tags are \"6..\").\n\nsubfield( $tag, $subfield )\nShortcut method for getting just a subfield for a tag. These are equivalent:\n\nmy $title = $marc->field('245')->subfield(\"a\");\nmy $title = $marc->subfield('245',\"a\");\n\nIf either the field or subfield can't be found, \"undef\" is returned.\n\nappendfields( @fields )\nAppends the field specified by $field to the end of the record. @fields need to be MARC::Field\nobjects.\n\nmy $field = MARC::Field->new('590','','','a' => 'My local note.');\n$record->appendfields($field);\n\nReturns the number of fields appended.\n\ninsertfieldsbefore( $beforefield, @newfields )\nInserts the field specified by $newfield before the field $beforefield. Returns the number of\nfields inserted, or undef on failures. Both $beforefield and all @newfields need to be\nMARC::Field objects. If they are not an exception will be thrown.\n\nmy $beforefield = $record->field('260');\nmy $newfield = MARC::Field->new('250','','','a' => '2nd ed.');\n$record->insertfieldsbefore($beforefield,$newfield);\n\ninsertfieldsafter( $afterfield, @newfields )\nIdentical to \"insertfieldsbefore()\", but fields are added after $afterfield. Remember,\n$afterfield and any new fields must be valid MARC::Field objects or else an exception will be\nthrown.\n\ninsertfieldsordered( @newfields )\nWill insert fields in strictly numerical order. So a 008 will be filed after a 001 field. See\n\"insertgroupedfield()\" for an additional ordering.\n\ninsertgroupedfield( $field )\nWill insert the specified MARC::Field object into the record in grouped order and return true\n(1) on success, and false (undef) on failure.\n\nmy $field = MARC::Field->new( '510', 'Indexed by Google.' );\n$record->insertgroupedfield( $field );\n\nFor example, if a '650' field is inserted with \"insertgroupedfield()\" it will be inserted at\nthe end of the 6XX group of tags. After discussion most people wanted the ability to add a new\nfield to the end of the hundred group where it belonged. The reason is that according to the\nMARC format, fields within a record are supposed to be grouped by block (hundred groups). This\nmeans that fields may not necessarily be in tag order.\n\ndeletefields( $field )\nDeletes a given list of MARC::Field objects from the the record.\n\n# delete all note fields\nmy @notes = $record->field('5..');\n$record->deletefields(@notes);\n",
                "subsections": [
                    {
                        "name": "delete_fields",
                        "content": "deletefield()\nSame thing as deletefields() but only expects a single MARC::Field to be passed in. Mainly here\nfor backwards compatibility.\n\nasusmarc()\nThis is a wrapper around \"MARC::File::USMARC::encode()\" for compatibility with older versions of\nMARC::Record.\n\nasformatted()\nReturns a pretty string for printing in a MARC dump.\n\nleader()\nReturns the leader for the record. Sets the leader if *text* is defined. No error checking is\ndone on the validity of the leader.\n\nencoding()\nA method for getting/setting the encoding for a record. The encoding for a record is determined\nby position 09 in the leader, which is blank for MARC-8 encoding, and 'a' for UCS/Unicode."
                    },
                    {
                        "name": "encoding",
                        "content": "If you want to set the encoding for a MARC::Record object you can use the string values:\n\n$record->encoding( 'UTF-8' );\n\nNOTE: MARC::Record objects created from scratch have an a default encoding of MARC-8, which has\nbeen the standard for years...but many online catlogs and record vendors are migrating to UTF-8.\n\nWARNING: you should be sure your record really does contain valid UTF-8 data when you manually\nset the encoding.\n\nsetleaderlengths( $reclen, $baseaddr )\nInternal function for updating the leader's length and base address.\n\nclone()\nThe \"clone()\" method makes a copy of an existing MARC record and returns the new version. Note\nthat you cannot just say:\n\nmy $newmarc = $oldmarc;\n\nThis just makes a copy of the reference, not a new object. You must use the \"clone()\" method\nlike so:\n\nmy $newmarc = $oldmarc->clone;\n\nYou can also specify field specs to filter down only a certain subset of fields. For instance,\nif you only wanted the title and ISBN tags from a record, you could do this:\n\nmy $smallmarc = $marc->clone( 245, '020' );\n\nThe order of the fields is preserved as it was in the original record.\n\nwarnings()\nReturns the warnings (as a list) that were created when the record was read. These are things\nlike \"Invalid indicators converted to blanks\".\n\nmy @warnings = $record->warnings();\n\nThe warnings are items that you might be interested in, or might not. It depends on how\nstringently you're checking data. If you're doing some grunt data analysis, you probably don't\ncare.\n\nA side effect of calling warnings() is that the warning buffer will be cleared.\n\naddfields()\n\"addfields()\" is now deprecated, and users are encouraged to use \"appendfields()\",\n\"insertfieldsafter()\", and \"insertfieldsbefore()\" since they do what you want probably. It\nis still here though, for backwards compatibility.\n\n\"addfields()\" adds MARC::Field objects to the end of the list. Returns the number of fields\nadded, or \"undef\" if there was an error.\n\nThere are three ways of calling \"addfields()\" to add data to the record.\n\n1 Create a MARC::Field object and add it\nmy $author = MARC::Field->new(\n100, \"1\", \" \", a => \"Arnosky, Jim.\"\n);\n$marc->addfields( $author );\n\n2 Add the data fields directly, and let \"addfields()\" take care of the objectifying.\n$marc->addfields(\n245, \"1\", \"0\",\na => \"Raccoons and ripe corn /\",\nc => \"Jim Arnosky.\",\n);\n\n3 Same as #2 above, but pass multiple fields of data in anonymous lists\n$marc->addfields(\n[ 250, \" \", \" \", a => \"1st ed.\" ],\n[ 650, \"1\", \" \", a => \"Raccoons.\" ],\n);\n"
                    }
                ]
            },
            "DESIGN NOTES": {
                "content": "A brief discussion of why MARC::Record is done the way it is:\n\n*   It's built for quick prototyping\n\nOne of the areas Perl excels is in allowing the programmer to create easy solutions quickly.\nMARC::Record is designed along those same lines. You want a program to dump all the 6XX tags\nin a file? MARC::Record is your friend.\n\n*   It's built for extensibility\n\nCurrently, I'm using MARC::Record for analyzing bibliographic data, but who knows what might\nhappen in the future? MARC::Record needs to be just as adept at authority data, too.\n\n*   It's designed around accessor methods\n\nI use method calls everywhere, and I expect calling programs to do the same, rather than\naccessing internal data directly. If you access an object's hash fields on your own, future\nreleases may break your code.\n\n*   It's not built for speed\n\nOne of the tradeoffs in using accessor methods is some overhead in the method calls. Is this\nslow? I don't know, I haven't measured. I would suggest that if you're a cycle junkie that\nyou use Benchmark.pm to check to see where your bottlenecks are, and then decide if\nMARC::Record is for you.\n",
                "subsections": []
            },
            "RELATED MODULES": {
                "content": "MARC::Field, MARC::Batch, MARC::File::XML, MARC::Charset, MARC::Lint\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   perl4lib (<http://perl4lib.perl.org/>)\n\nA mailing list devoted to the use of Perl in libraries.\n\n*   Library Of Congress MARC pages (<http://www.loc.gov/marc/>)\n\nThe definitive source for all things MARC.\n\n*   *Understanding MARC Bibliographic* (<http://lcweb.loc.gov/marc/umb/>)\n\nOnline version of the free booklet. An excellent overview of the MARC format. Essential.\n\n*   Tag Of The Month (<http://www.follettsoftware.com/sub/tagofthemonth/>)\n\nFollett Software Company's (<http://www.fsc.follett.com/>) monthly discussion of various\nMARC tags.\n",
                "subsections": []
            },
            "TODO": {
                "content": "*   Incorporate MARC.pm in the distribution.\n\nCombine MARC.pm and MARC::* into one distribution.\n\n*   Podify MARC.pm\n\n*   Allow regexes across the entire tag\n\nImagine something like this:\n\nmy @searsheadings = $marc->taggrep( qr/Sears/ );\n\n(from Mike O'Regan)\n\n*   Insert a field in an arbitrary place in the record\n\n*   Modifying an existing field\n\nBUGS, WISHES AND CORRESPONDENCE\nPlease feel free to email me at \"<mrylander@gmail.com>\". I'm glad to help as best I can, and I'm\nalways interested in bugs, suggestions and patches.\n\nAn excellent place to look for information, and get quick help, is from the perl4lib mailing\nlist. See <http://perl4lib.perl.org> for more information about this list, and other helpful\nMARC information.\n\nThe MARC::Record development team uses the RT bug tracking system at <http://rt.cpan.org>. If\nyour email is about a bug or suggestion, please report it through the RT system. This is a huge\nhelp for the team, and you'll be notified of progress as things get fixed or updated. If you\nprefer not to use the website, you can send your bug to \"<bug-MARC-Record@rt.cpan.org>\"\n",
                "subsections": []
            },
            "IDEAS": {
                "content": "Ideas are things that have been considered, but nobody's actually asked for.\n\n*   Create multiple output formats.\n\nThese could be ASCII or MarcMaker.\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This code may be distributed under the same terms as Perl itself.\n\nPlease note that these modules are not products of or supported by the employers of the various\ncontributors to the code.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   Andy Lester\n\n*   Mike O'Regan\n\n*   Ed Summers\n\n*   Mike Rylander\n\n*   Galen Charlton\n",
                "subsections": []
            }
        }
    }
}