MARC::Fast(3pm)
π MARC::Fast π
okay so bestie, welcome to MARC::Fast(3pm) β that's the User Contributed Perl Documentation corner of the manual, and honestly? this module ate. it's a very fast implementation of a MARC database reader, and it's about to be your new main character. π
β¨ NAME β¨
MARC::Fast β very fast implementation of MARC database reader π¦
πΈ SYNOPSIS πΈ
okay so the whole vibe is literally this:
use MARC::Fast;
my $marc = new MARC::Fast(
marcdb => 'unimarc.iso',
);
foreach my $mfn ( 1 .. $marc->count ) {
print $marc->to_ascii( $mfn );
}
and if you want a longer example, one that's got command line options and everything, go peek at dump_fastmarc.pl in scripts. it's giving demo energy. π
π¦ DESCRIPTION π¦
so this is the very fast alternative to the MARC and MARC::Record modules. like, speed. that's the whole point. ποΈβ¨
and ngl it's also very suitable for random access to MARC records β as opposed to doing it sequentially, one after another, like some kind of peasant. random access is the moment. π
π METHODS π
π new π
reads the MARC database. yes queen, it opens it up and everything.
my $marc = new MARC::Fast(
marcdb => 'unimarc.iso',
quiet => 0,
debug => 0,
assert => 0,
hash_filter => sub {
my ($t, $record_number) = @_;
$t =~ s/foo/bar/;
return $t;
},
);
π₯ count π₯
returns how many records are in the database. the headcount. the roster. the guest list. ποΈ
print $marc->count;
π fetch π
fetches a record from the database. grabby hands. π
my $hash = $marc->fetch(42);
heads up bestie: the first record number is 1. not zero. one. periodt. π
π last_leader π
returns the leader of the last record that got fetched. like, who's in charge of the most recent one. π
print $marc->last_leader;
okay so this got added in version 0.08 of this module, so if you actually need it you should write:
use MARC::Fast 0.08;
just to be sure it's supported. manifesting it into existence, fr fr. β¨
π§ to_hash π§
reads a record with the specified MFN and converts it into a hash. glow-up complete. π«
my $hash = $marc->to_hash( $mfn, include_subfields => 1,
hash_filter => sub { my ($l,$tag) = @_; return $l; }
);
it's got this ability to convert characters (using hash_filter) from the MARC database before creating the structures β which means you can re-map characters or do a quick little fix-up of your data. and listen: if you specify hash_filter in both new and to_hash, then only the one from to_hash gets used. to_hash wins. no debate. π
this function returns a hash that looks like this:
'200' => [
{
'i1' => '1',
'i2' => ' '
'a' => 'Goa',
'f' => 'Valdo D\'Arienzo',
'e' => 'tipografie e tipografi nel XVI secolo',
}
],
and this method also creates an additional field 000 with the MFN in it. bonus content, bestie. π
π to_ascii π
print $marc->to_ascii( 42 );
π«Ά UTF-8 ENCODING π«Ά
okay so this module does nothing with encoding. nothing at all. it's not its job. but here's the thing: since the MARC format is byte oriented β even when you're using UTF-8, which has a variable number of bytes for each character β the file gets opened in binary mode.
as a result, all the scalars returned to perl don't have the utf-8 flag. so what do you do? the solution is to use hash_filter and Encode to decode the utf-8 encoding, like this:
use Encode;
my $marc = new MARC::Fast(
marcdb => 'utf8.marc',
hash_filter => sub {
Encode::decode( 'utf-8', $_[0] );
},
);
this will affect to_hash, but fetch will still return binary representation since it doesn't support hash_filter. so don't come for fetch, it simply cannot. π
π AUTHOR π
the icon, the legend, the moment:
- Dobrica Pavlinusic
- CPAN ID:
DPAVLIN dpavlin@rot13.orghttp://www.rot13.org/~dpavlin/
πΈ COPYRIGHT πΈ
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay. π
the full text of the license can be found in the LICENSE file included with this module. go read it, it's right there. π
π SEE ALSO π
Biblio::Isisperl(1)
iykyk. π
okay that's the whole page bestie, we ate and left no crumbs π β this was MARC::Fast(3pm) from perl v5.36.0, dated 2023-01-29. go read some MARC records. mwah. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: libmarc-fast-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmarc-fast-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmarc-fast-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmarc-fast-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmarc-fast-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms