--- trunk/lib/Biblio/Isis.pm 2006/07/06 11:02:37 44 +++ trunk/lib/Biblio/Isis.pm 2006/07/07 23:45:12 54 @@ -4,12 +4,10 @@ use Carp; use File::Glob qw(:globally :nocase); -use Data::Dumper; - BEGIN { use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - $VERSION = 0.13; + $VERSION = 0.20; @ISA = qw (Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw (); @@ -119,7 +117,7 @@ =item debug -Dump a B of debugging output. +Dump a B of debugging output even at level 1. For even more increase level. =back @@ -153,7 +151,16 @@ } } - print STDERR "## using files: ",join(" ",@isis_files),"\n" if ($self->{debug}); + if ($self->{debug}) { + print STDERR "## using files: ",join(" ",@isis_files),"\n"; + eval "use Data::Dump"; + + if (! $@) { + *Dumper = *Data::Dump::dump; + } else { + use Data::Dumper; + } + } # if you want to read .FDT file use read_fdt argument when creating class! if ($self->{read_fdt} && -e $self->{fdt_file}) { @@ -202,7 +209,7 @@ read($self->{'fileMST'}, $buff, 4) || croak "can't read NXTMFN from MST: $!"; $self->{'NXTMFN'}=unpack("V",$buff) || croak "NXTNFN is zero"; - print STDERR Dumper($self),"\n" if ($self->{debug}); + print STDERR "## self ",Dumper($self),"\n" if ($self->{debug}); # open files for later open($self->{'fileXRF'}, $self->{xrf_file}) || croak "can't open '$self->{xrf_file}': $!"; @@ -378,6 +385,24 @@ return $self->{'record'}; } +=head2 mfn + +Returns current MFN position + + my $mfn = $isis->mfn; + +=cut + +# This function should be simple return $self->{current_mfn}, +# but if new is called with _hack_mfn it becomes setter. +# It's useful in tests when setting $isis->{record} directly + +sub mfn { + my $self = shift; + return $self->{current_mfn}; +}; + + =head2 to_ascii Returns ASCII output of record with specified MFN @@ -457,6 +482,13 @@ } ], +In case there are repeatable subfields in record, this will create +following structure: + + '900' => [ { + 'a' => [ 'foo', 'bar', 'baz' ], + }] + This method will also create additional field C<000> with MFN. =cut @@ -489,7 +521,21 @@ if ($l =~ m/\^/) { foreach my $t (split(/\^/,$l)) { next if (! $t); - $val->{substr($t,0,1)} = substr($t,1); + my ($sf,$v) = (substr($t,0,1), substr($t,1)); + # FIXME make this option ! + next unless ($v); +# warn "### $k^$sf:$v",$/ if ($self->{debug} > 1); + + # FIXME array return optional, by default unroll to ' ; ' + if (ref( $val->{$sf} ) eq 'ARRAY') { + + push @{ $val->{$sf} }, $v; + } elsif (defined( $val->{$sf} )) { + # convert scalar field to array + $val->{$sf} = [ $val->{$sf}, $v ]; + } else { + $val->{$sf} = $v; + } } } else { $val = $l; @@ -608,6 +654,18 @@ tested this against ouput of one C-based application, but I don't know any details about it's version. +=head1 VERSIONS + +You can find version dependencies documented here + +=over 8 + +=item 0.20 + +Added C<< $isis->mfn >> and support for repeatable subfields + +=back + =head1 AUTHOR Dobrica Pavlinusic