SHARE
TWEET

Simple use of __DATA__

a guest Feb 8th, 2013 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4.  
  5. print('<?xml version="1.0" encoding="utf-8"?>' . "\n");
  6. print('<collection xmlns="http://www.loc.gov/MARC21/slim">' . "\n");
  7.  
  8. my ($f, $fh);
  9. $f = 1;
  10. $fh = undef;
  11.  
  12. my $fp = "/home/jason/Src/evergreen/migration/trunk-hg/data/biblio.record_entry.%03d.file";
  13.  
  14. my $bib;
  15. while ($bib = <::DATA>) {
  16.     my $notfound = 1;
  17.     chomp $bib;
  18.     do {
  19.         open($fh, sprintf($fp, $f++)) if (!defined($fh));
  20.         my $line = <$fh>;
  21.         if ($line) {
  22.             if ($line =~/^$bib\t/) {
  23.                 my $record;
  24.                 $record = $1 if ($line =~ /(<record.*<\/record>)/);
  25.                 $record =~ s/ xmlns=\"[^\"]+\"//;
  26.                 print $record . "\n";
  27.                 $notfound = 0;
  28.             }
  29.         }
  30.         else {
  31.             close($fh);
  32.             $fh = undef;
  33.         }
  34.     } while ($notfound);
  35. }
  36. close($fh) if (defined($fh));
  37. print("</collection>\n");
  38.  
  39.  
  40. __DATA__
  41. 67759
  42. 207758
  43. 365138
  44. 398759
  45. 459563
  46. 840678
  47. 1086637
  48. 1096224
  49. 1130908
  50. 1239723
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top