{
    "content": [
        {
            "type": "text",
            "text": "# MARC::Field (perldoc)\n\n## NAME\n\nMARC::Field - Perl extension for handling MARC fields\n\n## SYNOPSIS\n\nuse MARC::Field;\n# If your system uses wacky control field tags, add them\nMARC::Field->allowcontrolfieldtags('FMT', 'LLE');\nmy $field = MARC::Field->new( 245, '1', '0',\n'a' => 'Raccoons and ripe corn / ',\n'c' => 'Jim Arnosky.'\n);\n$field->addsubfields( \"a\", \"1st ed.\" );\n\n## DESCRIPTION\n\nDefines MARC fields for use in the MARC::Record module. I suppose you could use them on their\nown, but that wouldn't be very interesting.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORT**\n- **CLASS VARIABLES**\n- **METHODS** (1 subsections)\n- **SEE ALSO**\n- **TODO**\n- **LICENSE**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MARC::Field",
        "section": "",
        "mode": "perldoc",
        "summary": "MARC::Field - Perl extension for handling MARC fields",
        "synopsis": "use MARC::Field;\n# If your system uses wacky control field tags, add them\nMARC::Field->allowcontrolfieldtags('FMT', 'LLE');\nmy $field = MARC::Field->new( 245, '1', '0',\n'a' => 'Raccoons and ripe corn / ',\n'c' => 'Jim Arnosky.'\n);\n$field->addsubfields( \"a\", \"1st ed.\" );",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "EXPORT",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "CLASS VARIABLES",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 93,
                "subsections": [
                    {
                        "name": "delete_subfield",
                        "lines": 121
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "TODO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MARC::Field - Perl extension for handling MARC fields\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use MARC::Field;\n\n# If your system uses wacky control field tags, add them\nMARC::Field->allowcontrolfieldtags('FMT', 'LLE');\n\nmy $field = MARC::Field->new( 245, '1', '0',\n'a' => 'Raccoons and ripe corn / ',\n'c' => 'Jim Arnosky.'\n);\n$field->addsubfields( \"a\", \"1st ed.\" );\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Defines MARC fields for use in the MARC::Record module. I suppose you could use them on their\nown, but that wouldn't be very interesting.\n",
                "subsections": []
            },
            "EXPORT": {
                "content": "None by default. Any errors are stored in $MARC::Field::ERROR, which $MARC::Record usually\nbubbles up to $MARC::Record::ERROR.\n",
                "subsections": []
            },
            "CLASS VARIABLES": {
                "content": "extracontrolfieldtags: Some systems (notably Ex Libris's Aleph) throw extra control fields in\ntheir MARC (e.g., Aleph's MARC-XML tends to have a \"FMT\" control field). We keep a class-level\nhash to track to track them; it can be manipulated with \"allowcontrolfieldtags\" and\nc<disallowcontrolfieldtags>.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new()\nThe constructor, which will return a MARC::Field object. Typically you will pass in the tag\nnumber, indicator 1, indicator 2, and then a list of any subfield/data pairs. For example:\n\nmy $field = MARC::Field->new(\n245, '1', '0',\n'a' => 'Raccoons and ripe corn / ',\n'c' => 'Jim Arnosky.'\n);\n\nOr if you want to add a control field (< 010) that does not have indicators.\n\nmy $field = MARC::Field->new( '001', ' 14919759' );\n\ntag()\nReturns the three digit tag for the field.\n\nsettag(tag)\nChanges the tag number of this field. Updates the control status accordingly. Will \"croak\" if an\ninvalid value is passed in.\n\nindicator(indno)\nReturns the specified indicator. Returns \"undef\" and logs a warning if field is a control field\nand thus doesn't have indicators. If the field is not a control field, croaks if the *indno* is\nnot 1 or 2.\n\nsetindicator($indno, $indval)\nSet the indicator position *$indno* to the value specified by *$indval*. Croaks if the indicator\nposition, is invalid, the field is a control field and thus doesn't have indicators, or if the\nnew indicator value is invalid.\n\nallowcontrolfieldtags($tag, $tag2, ...)\nAdd $tags to class-level list of strings to consider valid control fields tags (in addition to\n001 through 009). Tags must have three characters.\n\ndisallowcontrolfieldtags($tag, $tag2, ...)\n=head2 disallowcontrolfieldtags('*')\nRevoke the validity of a control field tag previously added with allowcontrolfieldtags. As a\nspecial case, if you pass the string '*' it will clear out all previously-added tags.\n\nNOTE that this will only deal with stuff added with allowcontrolfieldtags; you can't disallow\n'001'.\n\nisvalidtag($tag) -- is the given tag valid?\nGenerally called as a class method (e.g., MARC::Field->isvalidtag('001'))\n\nisvalidindicator($indval) -- is the given indicator value valid?\nGenerally called as a class method (e.g., MARC::Field->isvalidindicator('4'))\n\niscontrolfieldtag($tag) -- does the given tag denote a control field?\nGenerally called as a class method (e.g., MARC::Field->iscontrolfieldtag('001'))\n\niscontrolfield()\nTells whether this field is one of the control tags from 001-009.\n\nsubfield(code)\nWhen called in a scalar context returns the text from the first subfield matching the subfield\ncode.\n\nmy $subfield = $field->subfield( 'a' );\n\nOr if you think there might be more than one you can get all of them by calling in a list\ncontext:\n\nmy @subfields = $field->subfield( 'a' );\n\nIf no matching subfields are found, \"undef\" is returned in a scalar context and an empty list in\na list context.\n\nIf the tag is a control field, \"undef\" is returned and $MARC::Field::ERROR is set.\n\nsubfields()\nReturns all the subfields in the field. What's returned is a list of list refs, where the inner\nlist is a subfield code and the subfield data.\n\nFor example, this might be the subfields from a 245 field:\n\n(\n[ 'a', 'Perl in a nutshell :' ],\n[ 'b', 'A desktop quick reference.' ],\n)\n\ndata()\nReturns the data part of the field, if the tag number is less than 10.\n\naddsubfields(code,text[,code,text ...])\nAdds subfields to the end of the subfield list.\n\n$field->addsubfields( 'c' => '1985' );\n\nReturns the number of subfields added, or \"undef\" if there was an error.\n\ndeletesubfield()",
                "subsections": [
                    {
                        "name": "delete_subfield",
                        "content": "# delete any subfield a in the field\n$field->deletesubfield(code => 'a');\n\n# delete any subfield a or u in the field\n$field->deletesubfield(code => ['a', 'u']);\n\n# delete any subfield code matching a compiled regular expression\n$field->deletesubfield(code => qr/[^a-z0-9]/);\n\nIf you want to only delete subfields at a particular position you can use the pos parameter:\n\n# delete subfield u at the first position\n$field->deletesubfield(code => 'u', pos => 0);\n\n# delete subfield u at first or second position\n$field->deletesubfield(code => 'u', pos => [0,1]);\n\n# delete the second subfield, no matter what it is\n$field->deletesubfield(pos => 1);\n\nYou can specify a regex to for only deleting subfields that match:\n\n# delete any subfield u that matches zombo.com\n$field->deletesubfield(code => 'u', match => qr/zombo.com/);\n\n# delete any subfield that matches quux\n$field->deletesubfield(match => qr/quux/);\n\nYou can also pass a single subfield label:\n\n# delete all subfield u\n$field->deletesubfield('u');\n\ndeletesubfields()\nDelete all subfields with a given subfield code. This is here for backwards compatibility, you\nshould use the more flexible deletesubfield().\n\nupdate()\nAllows you to change the values of the field. You can update indicators and subfields like this:\n\n$field->update( ind2 => '4', a => 'The ballad of Abe Lincoln');\n\nIf you attempt to update a subfield which does not currently exist in the field, then a new\nsubfield will be appended to the field. If you don't like this auto-vivification you must check\nfor the existence of the subfield prior to update.\n\nif ( $field->subfield( 'a' ) ) {\n$field->update( 'a' => 'Cryptonomicon' );\n}\n\nIf you want to update a field that has no indicators or subfields (000-009) just call update()\nwith one argument, the string that you would like to set the field to.\n\n$field = $record->field( '003' );\n$field->update('IMchF');\n\nNote: when doing subfield updates be aware that \"update()\" will only update the first\noccurrence. If you need to do anything more complicated you will probably need to create a new\nfield and use \"replacewith()\".\n\nReturns the number of items modified.\n\nreplacewith()\nAllows you to replace an existing field with a new one. You need to pass \"replace()\" a\nMARC::Field object to replace the existing field with. For example:\n\n$field = $record->field('245');\nmy $newfield = new MARC::Field('245','0','4','The ballad of Abe Lincoln.');\n$field->replacewith($newfield);\n\nDoesn't return a meaningful or reliable value.\n\nasstring( [$subfields] [, $delimiter] )\nReturns a string of all subfields run together. A space is added to the result between each\nsubfield, unless the delimiter parameter is passed. The tag number and subfield character are\nnot included.\n\nSubfields appear in the output string in the order in which they occur in the field.\n\nIf $subfields is specified, then only those subfields will be included.\n\nmy $field = MARC::Field->new(\n245, '1', '0',\n'a' => 'Abraham Lincoln',\n'h' => '[videorecording] :',\n'b' => 'preserving the union /',\n'c' => 'A&E Home Video.'\n);\nprint $field->asstring( 'abh' ); # Only those three subfields\n# prints 'Abraham Lincoln [videorecording] : preserving the union /'.\nprint $field->asstring( 'ab', '--' ); # Only those two subfields, with a delimiter\n# prints 'Abraham Lincoln--preserving the union /'.\n\nNote that subfield h comes before subfield b in the output.\n\nasformatted()\nReturns a pretty string for printing in a MARC dump.\n\nasusmarc()\nReturns a string for putting into a USMARC file. It's really only useful for\n\"MARC::Record::asusmarc()\".\n\nclone()\nMakes a copy of the field. Note that this is not just the same as saying\n\nmy $newfield = $field;\n\nsince that just makes a copy of the reference. To get a new object, you must\n\nmy $newfield = $field->clone;\n\nReturns a MARC::Field record.\n\nwarnings()\nReturns the warnings that were created when the record was read. These are things like \"Invalid\nindicators converted to blanks\".\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"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "See the \"SEE ALSO\" section for MARC::Record.\n",
                "subsections": []
            },
            "TODO": {
                "content": "See the \"TODO\" section for MARC::Record.\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": []
            },
            "AUTHOR": {
                "content": "Andy Lester, \"<andy@petdance.com>\"\n",
                "subsections": []
            }
        }
    }
}