#!/usr/bin/perl # mylibrary2files.pl - find resources and save them to files # define use constant DATA => './data/'; use constant EAD => DATA . 'ead/'; use constant MARC => DATA . 'marc/'; use constant INSTANCE => 'crra'; # require use MyLibrary::Core; use strict; # configure MyLibrary::Config->instance( INSTANCE ); foreach ( MyLibrary::Resource->get_resources ) { my $file; my $content = $_->note; if ( $_->format eq 'MARC' ) { $file = MARC . $_->id . '.marc' } elsif ( $_->format eq 'XML' ) { $file = EAD . $_->id . '.xml' } open OUT, " > $file" or die "Can't open output ($file): $!\n"; print OUT $content; close OUT; }