--- trunk/lib/WebPAC/Output.pm 2007/11/27 23:45:28 1068 +++ trunk/lib/WebPAC/Output.pm 2007/11/27 23:54:43 1069 @@ -4,19 +4,14 @@ use strict; use Carp qw/confess/; +use Data::Dump qw/dump/; =head1 NAME WebPAC::Output - The great new WebPAC::Output! -=head1 VERSION - -Version 0.01 - =cut -our $VERSION = '0.01'; - =head1 SYNOPSIS Common routines for output formats @@ -26,7 +21,8 @@ =head2 ds_to_hash my $hash = $self->ds_to_hash( $ds, 'display' - disable_key_mungle => 1, + disable_key_mungle => 0, + singe_values = 0, ); =cut @@ -48,11 +44,23 @@ $name =~ s/\W+/_/g; } + my $v = $ds->{$t} || die "bug"; + # FIXME get rid of non hash values in data_structure for consistency? - next unless ref($ds->{$t}) eq 'HASH'; + next unless ref($v) eq 'HASH'; - if ( defined( $ds->{$t}->{$type} ) ) { - $hash->{$name} = $ds->{$t}->{$type}; + if ( defined( $v->{$type} ) ) { + if ( $opt->{single_values} && ref($v->{$type}) eq 'ARRAY' ) { + $hash->{$name} = join(' ', map { + if(ref($_)) { + dump($_); + } else { + $_; + } + } @{ $v->{$type} }); + } else { + $hash->{$name} = $v->{$type}; + } } }