line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Moose::Field::Std; |
2
|
|
|
|
|
|
|
# ABSTRACT: Standard Marc Field (tag >= 010) |
3
|
|
|
|
|
|
|
$MARC::Moose::Field::Std::VERSION = '1.0.44'; |
4
|
4
|
|
|
4
|
|
28
|
use Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'MARC::Moose::Field'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has ind1 => (is => 'rw', isa => 'Str', default => ' '); |
9
|
|
|
|
|
|
|
has ind2 => (is => 'rw', isa => 'Str', default => ' '); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has subf => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
override 'as_formatted' => sub { |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
join ' ', ( |
19
|
|
|
|
|
|
|
$self->tag, |
20
|
|
|
|
|
|
|
$self->ind1 . $self->ind2, |
21
|
|
|
|
|
|
|
map { ("\$$_->[0]", $_->[1]) } @{$self->subf} ); |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
override 'clone' => sub { |
26
|
|
|
|
|
|
|
my ($self, $tag) = @_; |
27
|
|
|
|
|
|
|
my $field = MARC::Moose::Field::Std->new( tag => $self->tag ); |
28
|
|
|
|
|
|
|
$field->tag($tag) if $tag; |
29
|
|
|
|
|
|
|
$field->subf( [ map { [ $_->[0] => $_->[1] ] } @{$self->subf} ] ); |
30
|
|
|
|
|
|
|
return $field; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub subfield { |
35
|
8
|
|
|
8
|
1
|
25
|
my ($self, $letter) = @_; |
36
|
|
|
|
|
|
|
|
37
|
8
|
50
|
|
|
|
20
|
return unless defined($letter); |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
11
|
my @values; |
40
|
8
|
|
|
|
|
14
|
for ( @{$self->subf} ) { |
|
8
|
|
|
|
|
234
|
|
41
|
14
|
100
|
|
|
|
110
|
push @values, $_->[1] if $_->[0] =~ $letter; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
8
|
50
|
|
|
|
24
|
return unless @values; |
45
|
8
|
50
|
|
|
|
44
|
return wantarray ? @values : $values[0]; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
MARC::Moose::Field::Std - Standard Marc Field (tag >= 010) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 1.0.44 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 subf |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
An ArrayRef of field subfields. Each subfield is this array is an 2D ArrayRef. |
71
|
|
|
|
|
|
|
For example: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$field->subf( [ [ 'a', 'Part1' ], [ 'b', 'Part2' ] ] ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
or |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$field->subf( [ [ a => 'Part1' ], [ b => 'Part2' ] ] ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 subfield( I<regexp> ) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
In scalar context, returns the first content of subfield which letter match |
84
|
|
|
|
|
|
|
regular expression C<regexp> . In list context, returns all subfields content. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
For example: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $field = MARC::Moose::Field::Std->new( |
89
|
|
|
|
|
|
|
tag => '600', |
90
|
|
|
|
|
|
|
subf => [ |
91
|
|
|
|
|
|
|
[ a => 'Part 1' ], |
92
|
|
|
|
|
|
|
[ x => '2010' ], |
93
|
|
|
|
|
|
|
[ a => 'Part 2' ], |
94
|
|
|
|
|
|
|
[ b => 'Part 3' ], |
95
|
|
|
|
|
|
|
] ); |
96
|
|
|
|
|
|
|
my $value = $field->subfield('a|b'); # Get 'Part 1' |
97
|
|
|
|
|
|
|
my @values = $field->subfield('a|b'); # Get ('Part1', 'Part 2') |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Frédéric Demians <f.demians@tamil.fr> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Frédéric Demians. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |