Debian Codegraph @

bin/marc2dc

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 marc2dc - convert a MARC record to Dublin Core
6
7 =head1 SYNOPSIS
8
9 % marc2dc [-q] marc.dat
10
11 =head1 DESCRIPTION
12
13 This script takes a MARC record as input and converts it
14 to an ad-hoc text format created from the conversion of the
15 record into Dublin Core.
16
17 =head1 TODO
18
19 =over 4
20
21 =item * generate more useful output
22
23 =back
24
25 =head1 AUTHOR
26
27 =over 4
28
29 =item * Brian Cassidy E<lt>[email protected]<gt>
30
31 =back
32
33 =head1 COPYRIGHT AND LICENSE
34
35 Copyright 2004 by Brian Cassidy
36
37 This library is free software; you can redistribute it and/or modify
38 it under the same terms as Perl itself.
39
40 =cut
41
42 use strict;
43 use warnings;
44
45 use MARC::Crosswalk::DublinCore;
46 use MARC::Record;
47 use File::Slurp;
48 use Getopt::Std;
49 use Pod::Usage;
50
51 our $VERSION = '0.01';
52
53 my %options;
54
55 getopts( 'q', \%options );
56
57 my $file = $ARGV[ 0 ];
58
59 HELP_MESSAGE() unless defined $file;
60
61 my $blob = read_file( $file );
62 my $marc = MARC::Record->new_from_usmarc( $blob );
63
64 my $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => $options{ q } );
65 my $dc = $crosswalk->as_dublincore( $marc );
66
67 for( $dc->elements ) {
68 my $qualifier = $_->qualifier;
69 my $scheme = $_->scheme;
70 printf( "%s: %s\n", $_->name . ( $qualifier ? ".$qualifier" : '' ) . ( $scheme ? "($scheme)" : '' ), $_->content );
71 }
72
73 sub HELP_MESSAGE {
74 pod2usage();
75 }