bug 4865: added dependency for using memcached for sessions
[koha.git] / C4 / Record.pm
1 package C4::Record;
2 #
3 # Copyright 2006 (C) LibLime
4 # Parts copyright 2010 BibLibre
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 #
22 use strict;
23 #use warnings; FIXME - Bug 2505
24
25 # please specify in which methods a given module is used
26 use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
27 use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
28 use MARC::Crosswalk::DublinCore; # marc2dcxml
29 use Biblio::EndnoteStyle;
30 use Unicode::Normalize; # _entity_encode
31 use XML::LibXSLT;
32 use XML::LibXML;
33 use C4::Biblio; #marc2bibtex
34 use C4::Csv; #marc2csv
35 use C4::Koha; #marc2csv
36 use YAML; #marcrecords2csv
37 use Text::CSV::Encoded; #marc2csv
38
39 use vars qw($VERSION @ISA @EXPORT);
40
41 # set the version for version checking
42 $VERSION = 3.00;
43
44 @ISA = qw(Exporter);
45
46 # only export API methods
47
48 @EXPORT = qw(
49   &marc2endnote
50   &marc2marc
51   &marc2marcxml
52   &marcxml2marc
53   &marc2dcxml
54   &marc2modsxml
55   &marc2bibtex
56   &marc2csv
57   &changeEncoding
58 );
59
60 =head1 NAME
61
62 C4::Record - MARC, MARCXML, DC, MODS, XML, etc. Record Management Functions and API
63
64 =head1 SYNOPSIS
65
66 New in Koha 3.x. This module handles all record-related management functions.
67
68 =head1 API (EXPORTED FUNCTIONS)
69
70 =head2 marc2marc - Convert from one flavour of ISO-2709 to another
71
72   my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding);
73
74 Returns an ISO-2709 scalar
75
76 =cut
77
78 sub marc2marc {
79         my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
80         my $error = "Feature not yet implemented\n";
81         return ($error,$marc);
82 }
83
84 =head2 marc2marcxml - Convert from ISO-2709 to MARCXML
85
86   my ($error,$marcxml) = marc2marcxml($marc,$encoding,$flavour);
87
88 Returns a MARCXML scalar
89
90 C<$marc> - an ISO-2709 scalar or MARC::Record object
91
92 C<$encoding> - UTF-8 or MARC-8 [UTF-8]
93
94 C<$flavour> - MARC21 or UNIMARC
95
96 C<$dont_entity_encode> - a flag that instructs marc2marcxml not to entity encode the xml before returning (optional)
97
98 =cut
99
100 sub marc2marcxml {
101         my ($marc,$encoding,$flavour,$dont_entity_encode) = @_;
102         my $error; # the error string
103         my $marcxml; # the final MARCXML scalar
104
105         # test if it's already a MARC::Record object, if not, make it one
106         my $marc_record_obj;
107         if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
108                 $marc_record_obj = $marc;
109         } else { # it's not a MARC::Record object, make it one
110                 eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions
111
112                 # conversion to MARC::Record object failed, populate $error
113                 if ($@) { $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR };
114         }
115         # only proceed if no errors so far
116         unless ($error) {
117
118                 # check the record for warnings
119                 my @warnings = $marc_record_obj->warnings();
120                 if (@warnings) {
121                         warn "\nWarnings encountered while processing ISO-2709 record with title \"".$marc_record_obj->title()."\":\n";
122                         foreach my $warn (@warnings) { warn "\t".$warn };
123                 }
124                 unless($encoding) {$encoding = "UTF-8"}; # set default encoding
125                 unless($flavour) {$flavour = C4::Context->preference("marcflavour")}; # set default MARC flavour
126
127                 # attempt to convert the record to MARCXML
128                 eval { $marcxml = $marc_record_obj->as_xml_record($flavour) }; #handle exceptions
129
130                 # record creation failed, populate $error
131                 if ($@) {
132                         $error .= "Creation of MARCXML failed:".$MARC::File::ERROR;
133                         $error .= "Additional information:\n";
134                         my @warnings = $@->warnings();
135                         foreach my $warn (@warnings) { $error.=$warn."\n" };
136
137                 # record creation was successful
138         } else {
139
140                         # check the record for warning flags again (warnings() will be cleared already if there was an error, see above block
141                         @warnings = $marc_record_obj->warnings();
142                         if (@warnings) {
143                                 warn "\nWarnings encountered while processing ISO-2709 record with title \"".$marc_record_obj->title()."\":\n";
144                                 foreach my $warn (@warnings) { warn "\t".$warn };
145                         }
146                 }
147
148                 # only proceed if no errors so far
149                 unless ($error) {
150
151                         # entity encode the XML unless instructed not to
152                 unless ($dont_entity_encode) {
153                         my ($marcxml_entity_encoded) = _entity_encode($marcxml);
154                         $marcxml = $marcxml_entity_encoded;
155                 }
156                 }
157         }
158         # return result to calling program
159         return ($error,$marcxml);
160 }
161
162 =head2 marcxml2marc - Convert from MARCXML to ISO-2709
163
164   my ($error,$marc) = marcxml2marc($marcxml,$encoding,$flavour);
165
166 Returns an ISO-2709 scalar
167
168 C<$marcxml> - a MARCXML record
169
170 C<$encoding> - UTF-8 or MARC-8 [UTF-8]
171
172 C<$flavour> - MARC21 or UNIMARC
173
174 =cut
175
176 sub marcxml2marc {
177     my ($marcxml,$encoding,$flavour) = @_;
178         my $error; # the error string
179         my $marc; # the final ISO-2709 scalar
180         unless($encoding) {$encoding = "UTF-8"}; # set the default encoding
181         unless($flavour) {$flavour = C4::Context->preference("marcflavour")}; # set the default MARC flavour
182
183         # attempt to do the conversion
184         eval { $marc = MARC::Record->new_from_xml($marcxml,$encoding,$flavour) }; # handle exceptions
185
186         # record creation failed, populate $error
187         if ($@) {$error .="\nCreation of MARCXML Record failed: ".$@;
188                 $error.=$MARC::File::ERROR if ($MARC::File::ERROR);
189                 };
190         # return result to calling program
191         return ($error,$marc);
192 }
193
194 =head2 marc2dcxml - Convert from ISO-2709 to Dublin Core
195
196   my ($error,$dcxml) = marc2dcxml($marc,$qualified);
197
198 Returns a DublinCore::Record object, will eventually return a Dublin Core scalar
199
200 FIXME: should return actual XML, not just an object
201
202 C<$marc> - an ISO-2709 scalar or MARC::Record object
203
204 C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0]
205
206 =cut
207
208 sub marc2dcxml {
209         my ($marc,$qualified) = @_;
210         my $error;
211     # test if it's already a MARC::Record object, if not, make it one
212     my $marc_record_obj;
213     if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
214         $marc_record_obj = $marc;
215     } else { # it's not a MARC::Record object, make it one
216                 eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions
217
218                 # conversion to MARC::Record object failed, populate $error
219                 if ($@) {
220                         $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR;
221                 }
222         }
223         my $crosswalk = MARC::Crosswalk::DublinCore->new;
224         if ($qualified) {
225                 $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
226         }
227         my $dcxml = $crosswalk->as_dublincore($marc_record_obj);
228         my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
229         $dcxmlfinal .= "<metadata
230   xmlns=\"http://example.org/myapp/\"
231   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
232   xsi:schemaLocation=\"http://example.org/myapp/ http://example.org/myapp/schema.xsd\"
233   xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
234   xmlns:dcterms=\"http://purl.org/dc/terms/\">";
235
236         foreach my $element ( $dcxml->elements() ) {
237                 $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n";
238     }
239         $dcxmlfinal .= "\n</metadata>";
240         return ($error,$dcxmlfinal);
241 }
242
243 =head2 marc2modsxml - Convert from ISO-2709 to MODS
244
245   my ($error,$modsxml) = marc2modsxml($marc);
246
247 Returns a MODS scalar
248
249 =cut
250
251 sub marc2modsxml {
252         my ($marc) = @_;
253         # grab the XML, run it through our stylesheet, push it out to the browser
254         my $xmlrecord = marc2marcxml($marc);
255         my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/MARC21slim2MODS3-1.xsl";
256         my $parser = XML::LibXML->new();
257         my $xslt = XML::LibXSLT->new();
258         my $source = $parser->parse_string($xmlrecord);
259         my $style_doc = $parser->parse_file($xslfile);
260         my $stylesheet = $xslt->parse_stylesheet($style_doc);
261         my $results = $stylesheet->transform($source);
262         my $newxmlrecord = $stylesheet->output_string($results);
263         return ($newxmlrecord);
264 }
265
266 sub marc2endnote {
267     my ($marc) = @_;
268         my $marc_rec_obj =  MARC::Record->new_from_usmarc($marc);
269         my $f260 = $marc_rec_obj->field('260');
270         my $f260a = $f260->subfield('a') if $f260;
271     my $f710 = $marc_rec_obj->field('710');
272     my $f710a = $f710->subfield('a') if $f710;
273         my $f500 = $marc_rec_obj->field('500');
274         my $abstract = $f500->subfield('a') if $f500;
275         my $fields = {
276                 DB => C4::Context->preference("LibraryName"),
277                 Title => $marc_rec_obj->title(),        
278                 Author => $marc_rec_obj->author(),      
279                 Publisher => $f710a,
280                 City => $f260a,
281                 Year => $marc_rec_obj->publication_date,
282                 Abstract => $abstract,
283         };
284         my $endnote;
285         my $style = new Biblio::EndnoteStyle();
286         my $template;
287         $template.= "DB - DB\n" if C4::Context->preference("LibraryName");
288         $template.="T1 - Title\n" if $marc_rec_obj->title();
289         $template.="A1 - Author\n" if $marc_rec_obj->author();
290         $template.="PB - Publisher\n" if  $f710a;
291         $template.="CY - City\n" if $f260a;
292         $template.="Y1 - Year\n" if $marc_rec_obj->publication_date;
293         $template.="AB - Abstract\n" if $abstract;
294         my ($text, $errmsg) = $style->format($template, $fields);
295         return ($text);
296         
297 }
298
299 =head2 marc2csv - Convert several records from UNIMARC to CSV
300
301   my ($csv) = marc2csv($biblios, $csvprofileid);
302
303 Pre and postprocessing can be done through a YAML file
304
305 Returns a CSV scalar
306
307 C<$biblio> - a list of biblionumbers
308
309 C<$csvprofileid> - the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv)
310
311 =cut
312
313 sub marc2csv {
314     my ($biblios, $id) = @_;
315     my $output;
316     my $csv = Text::CSV::Encoded->new();
317
318     # Getting yaml file
319     my $configfile = "../tools/csv-profiles/$id.yaml";
320     my ($preprocess, $postprocess, $fieldprocessing);
321     if (-e $configfile){
322         ($preprocess,$postprocess, $fieldprocessing) = YAML::LoadFile($configfile);
323     }
324
325     # Preprocessing
326     eval $preprocess if ($preprocess);
327
328     my $firstpass = 1;
329     foreach my $biblio (@$biblios) {
330         $output .= marcrecord2csv($biblio, $id, $firstpass, $csv, $fieldprocessing) ;
331         $firstpass = 0;
332     }
333
334     # Postprocessing
335     eval $postprocess if ($postprocess);
336
337     return $output;
338 }
339
340 =head2 marcrecord2csv - Convert a single record from UNIMARC to CSV
341
342   my ($csv) = marcrecord2csv($biblio, $csvprofileid, $header);
343
344 Returns a CSV scalar
345
346 C<$biblio> - a biblionumber
347
348 C<$csvprofileid> - the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv)
349
350 C<$header> - true if the headers are to be printed (typically at first pass)
351
352 C<$csv> - an already initialised Text::CSV object
353
354 =cut
355
356
357 sub marcrecord2csv {
358     my ($biblio, $id, $header, $csv, $fieldprocessing) = @_;
359     my $output;
360
361     # Getting the record
362     my $record = GetMarcBiblio($biblio);
363     next unless $record;
364     # Getting the framework
365     my $frameworkcode = GetFrameworkCode($biblio);
366
367     # Getting information about the csv profile
368     my $profile = GetCsvProfile($id);
369
370     # Getting output encoding
371     my $encoding          = $profile->{encoding} || 'utf8';
372     # Getting separators
373     my $csvseparator      = $profile->{csv_separator}      || ',';
374     my $fieldseparator    = $profile->{field_separator}    || '#';
375     my $subfieldseparator = $profile->{subfield_separator} || '|';
376
377     # TODO: Be more generic (in case we have to handle other protected chars or more separators)
378     if ($csvseparator eq '\t') { $csvseparator = "\t" }
379     if ($fieldseparator eq '\t') { $fieldseparator = "\t" }
380     if ($subfieldseparator eq '\t') { $subfieldseparator = "\t" }
381     if ($csvseparator eq '\n') { $csvseparator = "\n" }
382     if ($fieldseparator eq '\n') { $fieldseparator = "\n" }
383     if ($subfieldseparator eq '\n') { $subfieldseparator = "\n" }
384
385     $csv = $csv->encoding_out($encoding) ;
386     $csv->sep_char($csvseparator);
387
388     # Getting the marcfields
389     my $marcfieldslist = $profile->{marcfields};
390
391     # Getting the marcfields as an array
392     my @marcfieldsarray = split('\|', $marcfieldslist);
393
394    # Separating the marcfields from the the user-supplied headers
395     my @marcfields;
396     foreach (@marcfieldsarray) {
397         my @result = split('=', $_);
398         if (scalar(@result) == 2) {
399            push @marcfields, { header => $result[0], field => $result[1] }; 
400         } else {
401            push @marcfields, { field => $result[0] }
402         }
403     }
404
405     # If we have to insert the headers
406     if ($header) {
407         my @marcfieldsheaders;
408         my $dbh   = C4::Context->dbh;
409
410         # For each field or subfield
411         foreach (@marcfields) {
412
413             my $field = $_->{field};
414
415             # If we have a user-supplied header, we use it
416             if (exists $_->{header}) {
417                     push @marcfieldsheaders, $_->{header};
418             } else {
419                 # If not, we get the matching tag name from koha
420                 if (index($field, '$') > 0) {
421                     my ($fieldtag, $subfieldtag) = split('\$', $field);
422                     my $query = "SELECT liblibrarian FROM marc_subfield_structure WHERE tagfield=? AND tagsubfield=?";
423                     my $sth = $dbh->prepare($query);
424                     $sth->execute($fieldtag, $subfieldtag);
425                     my @results = $sth->fetchrow_array();
426                     push @marcfieldsheaders, $results[0];
427                 } else {
428                     my $query = "SELECT liblibrarian FROM marc_tag_structure WHERE tagfield=?";
429                     my $sth = $dbh->prepare($query);
430                     $sth->execute($field);
431                     my @results = $sth->fetchrow_array();
432                     push @marcfieldsheaders, $results[0];
433                 }
434             }
435         }
436         $csv->combine(@marcfieldsheaders);
437         $output = $csv->string() . "\n";        
438     }
439
440     # For each marcfield to export
441     my @fieldstab;
442     foreach (@marcfields) {
443         my $marcfield = $_->{field};
444         # If it is a subfield
445         if (index($marcfield, '$') > 0) {
446             my ($fieldtag, $subfieldtag) = split('\$', $marcfield);
447             my @fields = $record->field($fieldtag);
448             my @tmpfields;
449
450             # For each field
451             foreach my $field (@fields) {
452
453                 # We take every matching subfield
454                 my @subfields = $field->subfield($subfieldtag);
455                 foreach my $subfield (@subfields) {
456
457                     # Getting authorised value
458                     my $authvalues = GetKohaAuthorisedValuesFromField($fieldtag, $subfieldtag, $frameworkcode, undef);
459                     push @tmpfields, (defined $authvalues->{$subfield}) ? $authvalues->{$subfield} : $subfield;
460                 }
461             }
462             push (@fieldstab, join($subfieldseparator, @tmpfields));            
463         # Or a field
464         } else {
465             my @fields = ($record->field($marcfield));
466             my $authvalues = GetKohaAuthorisedValuesFromField($marcfield, undef, $frameworkcode, undef);
467
468             my @valuesarray;
469             foreach (@fields) {
470                 my $value;
471
472                 # Getting authorised value
473                 $value = defined $authvalues->{$_->as_string} ? $authvalues->{$_->as_string} : $_->as_string;
474
475                 # Field processing
476                 eval $fieldprocessing if ($fieldprocessing);
477
478                 push @valuesarray, $value;
479             }
480             push (@fieldstab, join($fieldseparator, @valuesarray)); 
481          }
482     };
483
484     $csv->combine(@fieldstab);
485     $output .= $csv->string() . "\n";
486
487     return $output;
488
489 }
490
491
492 =head2 changeEncoding - Change the encoding of a record
493
494   my ($error, $newrecord) = changeEncoding($record,$format,$flavour,$to_encoding,$from_encoding);
495
496 Changes the encoding of a record
497
498 C<$record> - the record itself can be in ISO-2709, a MARC::Record object, or MARCXML for now (required)
499
500 C<$format> - MARC or MARCXML (required)
501
502 C<$flavour> - MARC21 or UNIMARC, if MARC21, it will change the leader (optional) [defaults to Koha system preference]
503
504 C<$to_encoding> - the encoding you want the record to end up in (optional) [UTF-8]
505
506 C<$from_encoding> - the encoding the record is currently in (optional, it will probably be able to tell unless there's a problem with the record)
507
508 FIXME: the from_encoding doesn't work yet
509
510 FIXME: better handling for UNIMARC, it should allow management of 100 field
511
512 FIXME: shouldn't have to convert to and from xml/marc just to change encoding someone needs to re-write MARC::Record's 'encoding' method to actually alter the encoding rather than just changing the leader
513
514 =cut
515
516 sub changeEncoding {
517         my ($record,$format,$flavour,$to_encoding,$from_encoding) = @_;
518         my $newrecord;
519         my $error;
520         unless($flavour) {$flavour = C4::Context->preference("marcflavour")};
521         unless($to_encoding) {$to_encoding = "UTF-8"};
522         
523         # ISO-2709 Record (MARC21 or UNIMARC)
524         if (lc($format) =~ /^marc$/o) {
525                 # if we're converting encoding of an ISO2709 file, we need to roundtrip through XML
526                 #       because MARC::Record doesn't directly provide us with an encoding method
527                 #       It's definitely less than idea and should be fixed eventually - kados
528                 my $marcxml; # temporary storage of MARCXML scalar
529                 ($error,$marcxml) = marc2marcxml($record,$to_encoding,$flavour);
530                 unless ($error) {
531                         ($error,$newrecord) = marcxml2marc($marcxml,$to_encoding,$flavour);
532                 }
533         
534         # MARCXML Record
535         } elsif (lc($format) =~ /^marcxml$/o) { # MARCXML Record
536                 my $marc;
537                 ($error,$marc) = marcxml2marc($record,$to_encoding,$flavour);
538                 unless ($error) {
539                         ($error,$newrecord) = marc2marcxml($record,$to_encoding,$flavour);
540                 }
541         } else {
542                 $error.="Unsupported record format:".$format;
543         }
544         return ($error,$newrecord);
545 }
546
547 =head2 marc2bibtex - Convert from MARC21 and UNIMARC to BibTex
548
549   my ($bibtex) = marc2bibtex($record, $id);
550
551 Returns a BibTex scalar
552
553 C<$record> - a MARC::Record object
554
555 C<$id> - an id for the BibTex record (might be the biblionumber)
556
557 =cut
558
559
560 sub marc2bibtex {
561     my ($record, $id) = @_;
562     my $tex;
563
564     # Authors
565     my $marcauthors = GetMarcAuthors($record,C4::Context->preference("marcflavour"));
566     my $author;
567     for my $authors ( map { map { @$_ } values %$_  } @$marcauthors  ) {  
568         $author .= " and " if ($author && $$authors{value});
569         $author .= $$authors{value} if ($$authors{value}); 
570     }
571
572     # Defining the conversion hash according to the marcflavour
573     my %bh;
574     if (C4::Context->preference("marcflavour") eq "UNIMARC") {
575         
576         # FIXME, TODO : handle repeatable fields
577         # TODO : handle more types of documents
578
579         # Unimarc to bibtex hash
580         %bh = (
581
582             # Mandatory
583             author    => $author,
584             title     => $record->subfield("200", "a") || "",
585             editor    => $record->subfield("210", "g") || "",
586             publisher => $record->subfield("210", "c") || "",
587             year      => $record->subfield("210", "d") || $record->subfield("210", "h") || "",
588
589             # Optional
590             volume  =>  $record->subfield("200", "v") || "",
591             series  =>  $record->subfield("225", "a") || "",
592             address =>  $record->subfield("210", "a") || "",
593             edition =>  $record->subfield("205", "a") || "",
594             note    =>  $record->subfield("300", "a") || "",
595             url     =>  $record->subfield("856", "u") || ""
596         );
597     } else {
598
599         # Marc21 to bibtex hash
600         %bh = (
601
602             # Mandatory
603             author    => $author,
604             title     => $record->subfield("245", "a") || "",
605             editor    => $record->subfield("260", "f") || "",
606             publisher => $record->subfield("260", "b") || "",
607             year      => $record->subfield("260", "c") || $record->subfield("260", "g") || "",
608
609             # Optional
610             # unimarc to marc21 specification says not to convert 200$v to marc21
611             series  =>  $record->subfield("490", "a") || "",
612             address =>  $record->subfield("260", "a") || "",
613             edition =>  $record->subfield("250", "a") || "",
614             note    =>  $record->subfield("500", "a") || "",
615             url     =>  $record->subfield("856", "u") || ""
616         );
617     }
618
619     $tex .= "\@book{";
620     $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = "$bh{$_}") : () } keys %bh);
621     $tex .= "\n}\n";
622
623     return $tex;
624 }
625
626
627 =head1 INTERNAL FUNCTIONS
628
629 =head2 _entity_encode - Entity-encode an array of strings
630
631   my ($entity_encoded_string) = _entity_encode($string);
632
633 or
634
635   my (@entity_encoded_strings) = _entity_encode(@strings);
636
637 Entity-encode an array of strings
638
639 =cut
640
641 sub _entity_encode {
642         my @strings = @_;
643         my @strings_entity_encoded;
644         foreach my $string (@strings) {
645                 my $nfc_string = NFC($string);
646                 $nfc_string =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
647                 push @strings_entity_encoded, $nfc_string;
648         }
649         return @strings_entity_encoded;
650 }
651
652 END { }       # module clean-up code here (global destructor)
653 1;
654 __END__
655
656 =head1 AUTHOR
657
658 Joshua Ferraro <jmf@liblime.com>
659
660 =head1 MODIFICATIONS
661
662
663 =cut