MARC/Perl
MARC Tutorial
If you want to pull records out of the same database and do something with them, here's a template script:
| 1 | #!/usr/bin/perl -w |
|---|---|
| 2 | |
| 3 | # Script that gets MARC records (in blobs) from a database. |
| 4 | # Last updated 2004-09-08 Mark Jordan, mjordan@sfu.ca |
| 5 | |
| 6 | use strict; |
| 7 | use MARC::Record; |
| 8 | use DBI; |
| 9 | |
| 10 | # DB connection settings |
| 11 | my $mysql_host = "somehost"; |
| 12 | my $mysql_user = "someuser"; |
| 13 | my $mysql_password = "somepass*"; |
| 14 | my $mysql_database = "somedb"; |
| 15 | |
| 16 | |
| 17 | my $handle = DBI->connect("DBI:mysql:$mysql_database:$mysql_host", |
| 18 | "$mysql_user","$mysql_password") or die $DBI::errstr; |
| 19 | |
| 20 | my $SQL = "select * from Titles"; |
| 21 | my $cursor = $handle->prepare($SQL); |
| 22 | $cursor->execute; |
| 23 | |
| 24 | while (my @Records = $cursor->fetchrow_array) { |
| 25 | my $RawMARC = $Records[3]; |
| 26 | my $mrec = MARC::Record->new_from_usmarc($RawMARC); |
| 27 | # Print out the title |
| 28 | print $mrec->title , "\n"; |
| 29 | } |
| 30 | |
| 31 | $cursor->finish; |
| 32 | $handle->disconnect; |
| 33 | |
| 34 | __END__ |
Procite/Endnote
CONTRIBUTORS
Many thanks to all the contributors who have made this document possible.
- Bryan Baldus <eijabb@cpan.org>
- Chris Biemesderfer <chris@seagoat.com>
- Morbus Iff <morbus@disobey.com>
- Mark Jordan <mjordan@sfu.ca>
- Andy Lester <andy@petdance.com>
- Christopher Morgan <morgan@acm.org>
- Shashi Pinheiro <SPinheiro@utsa.edu>
- Jackie Shieh <jshieh@umich.edu>
- Ed Summers <ehs@pobox.com>
