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
=head2 ds_to_hash
my $hash = $self->ds_to_hash( $ds, 'display'
- disable_key_mungle => 1,
+ disable_key_mungle => 0,
+ singe_values = 0,
);
=cut
$name =~ s/\W+/_/g;
}
- # FIXME get rid of non hash values in data_structure for consistency?
- next unless ref($ds->{$t}) eq 'HASH';
+ my $v = $ds->{$t} || die "bug";
- if ( defined( $ds->{$t}->{$type} ) ) {
- $hash->{$name} = $ds->{$t}->{$type};
+ # FIXME get rid of non hash values in data_structure for consistency?
+ next unless ref($v) eq 'HASH';
+
+ 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};
+ }
}
}