App-MARC-Filter

 view release on metacpan or  search on metacpan

Filter.pm  view on Meta::CPAN

use IO::Uncompress::AnyUncompress qw($AnyUncompressError);
use List::Util 1.33 qw(any none);
use MARC::Batch;
use MARC::File::XML (BinaryEncoding => 'utf8', RecordFormat => 'MARC21');
use MARC::File::USMARC;
use MARC::Leader;
use MARC::Leader::Utils 0.02 qw(check_material_type  material_type);
use Readonly;
use Unicode::UTF8 qw(encode_utf8 decode_utf8);

Readonly::Array our @OUTPUT_FORMATS => qw(ascii xml);
Readonly::Array our @CONTROL_FIELDS => qw(001 003 005 006 007 008);

our $VERSION = 0.10;

$| = 1;

# Constructor.
sub new {
	my ($class, @params) = @_;

Filter.pm  view on Meta::CPAN

	}
	$self->{'_marc_value'} = shift @ARGV;
	if (! defined $self->{'_marc_value'}) {
		$self->_usage;
		return 1;
	} else {
		$self->{'_marc_value'} = decode_utf8($self->{'_marc_value'});
	}

	# Check output format.
	if (none { $self->{'_opts'}->{'o'} eq $_ } @OUTPUT_FORMATS) {
		err "Output format '$self->{'_opts'}->{'o'}' doesn't supported.";
	}

	# Check material type.
	if ($self->{'_marc_field'} eq 'material_type'
		&& ! check_material_type($self->{'_marc_value'})) {

		err 'Bad material type.',
			'Value', $self->{'_marc_value'},
		;



( run in 1.349 second using v1.01-cache-2.11-cpan-13bb782fe5a )