Bundle-PBib
view release on metacpan or search on metacpan
lib/Biblio/bp/lib/bp-endnote.pl view on Meta::CPAN
return undef if eof;
$ent = $_;
if ($opt_readline) {
while (<$bib'glb_current_fh>) {
last unless /\S/;
$ent .= $_;
}
} else {
local($/) = '';
$ent .= scalar(<$bib'glb_current_fh>);
}
$ent;
}
######
sub explode {
local($rec) = @_;
local($field, $value);
local(%entry);
local(@lines);
substr($rec, 0, 0) = "\n";
@lines = split(/\n\%/, $rec);
shift @lines;
foreach (@lines) {
$field = substr($_, 0, 1);
if (length($_) < 3) {
&bib'gotwarn("refer explode got empty field \%$field");
next;
}
$value = substr($_, 2);
$value =~ s/\n+/ /g;
$value =~ s/^\s+//;
$value =~ s/\s+$//;
if (defined $entry{$field}) {
$opt_validate && $opt_multFieldList !~ /\b$field\b/
&& &bib'gotwarn("Field $field multiply defined");
$entry{$field} .= $bib'cs_sep . $value;
} else {
$entry{$field} = $value;
}
}
%entry;
}
######
sub implode {
local(%entry) = @_;
$ent = '';
local(@keys) = sort { index($opt_order,$a) <=> index($opt_order,$b) }
keys(%entry);
local($unknown_ent) = '';
# unknown fields are at the top
foreach $field (@keys) {
last if index($opt_order,$field) >= $[;
&bib'gotwarn("refer implode: unknown field identifier: $field");
$unknown_ent .= "\%$field $entry{$field}\n" if length($field) == 1;
shift @keys;
}
foreach $field (@keys) {
$entry{$field} =~ s/$bib'cs_sep/\n\%$field /go;
$ent .= "\%$field $entry{$field}\n";
}
$ent .= $unknown_ent;
$ent =~ s/$bib'cs_sep/ /go;
$ent;
}
######
%ref_to_can_fields = (
'L', 'CiteKey',
'A', 'Authors',
'E', 'Editors',
'T', 'Title',
'B', 'SuperTitle',
'J', 'Journal',
'S', 'Series',
'V', 'Volume',
'N', 'Number',
'P', 'Pages',
'I', 'Publisher',
'C', 'PubAddress',
'$', 'Price',
'*', 'Copyright',
'K', 'Keywords',
'M', 'MRNumber',
'l', 'Language',
'U', 'Annotation',
'X', 'Abstract',
'G', 'GovNumber',
'O', 'Note',
'Q', 'CorpAuthor',
'W', 'Location',
'Y', 'Contents',
'Z', 'PagesWhole',
);
# Generate the opposite map upon loading the format.
local($key, $val);
while (($key, $val) = each %ref_to_can_fields) {
$can_to_ref_fields{$val} = $key;
}
undef $key; undef $val;
%end_to_can_types = (
'Journal Article', 'article',
'Book', 'book',
'Book Section', 'inbook',
'Edited Book', 'book',
'Magazine Article', 'article',
'Newspaper Article', 'article',
'Conference Proceedings', 'proceedings',
( run in 3.004 seconds using v1.01-cache-2.11-cpan-7f9471e7e0a )