NAME
    MARC::Leader::Utils - Utilities for MARC::Leader.

SYNOPSIS
     use MARC::Leader::Utils qw(material_type);

     my $bool = check_material_type($material_type);
     my $material_type = material_type($leader_obj);

DESCRIPTION
    The Perl module with common utilities for work with MARC leader field.

SUBROUTINES
  "check_material_type"
     my $bool = check_material_type($material_type);

    Check if material type string is valid.

    Possible strings are book, computer_file, continuing_resource, map,
    mixed_material, music and visual_material.

    Returns 0/1.

  "material_type"
     my $material_type = material_type($leader_obj);

    Get material type. This process is defined in MARC 008 field.

    $leader_obj variable is Data::MARC::Leader instace.

    Returned strings are:

    *       book

    *       computer_file

    *       continuing_resource

    *       map

    *       mixed_material

    *       music

    *       visual_material

    Returns string.

ERRORS
     material_type():
             Leader object must be a Data::MARC::Leader instance.
             Unsupported material type.

EXAMPLE1
     use strict;
     use warnings;

     use MARC::Leader::Utils qw(check_material_type);

     if (@ARGV < 1) {
             print STDERR "Usage: $0 material_type\n";
             exit 1;
     }
     my $material_type = $ARGV[0];

     my $ret = check_material_type($material_type);

     print "Expected material type: $material_type\n";
     print "Result: $ret\n";

     # Output (book):
     # Expected material type: book
     # Result: 1

     # Output (foo):
     # Expected material type: foo
     # Result: 0

EXAMPLE2
     use strict;
     use warnings;

     use MARC::Leader;
     use MARC::Leader::Utils qw(material_type);

     if (@ARGV < 1) {
             print STDERR "Usage: $0 leader_string\n";
             exit 1;
     }
     my $leader_string = $ARGV[0];

     my $leader = MARC::Leader->new->parse($leader_string);

     my $material_type = material_type($leader);

     print "Leader: |$leader_string|\n";
     print "Material type: $material_type\n";

     # Output for '     nem a22     2  4500':
     # Leader: |     nem a22     2  4500|
     # Material type: map

DEPENDENCIES
    Error::Pure, Exporter, File::Spec::Functions, File::Share, Readonly.

SEE ALSO
    Data::MARC::Leader
        Data object for MARC leader.

    MARC::Leader
        MARC leader class.

REPOSITORY
    <https://github.com/michal-josef-spacek/MARC-Leader-Utils>

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2025 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.02

