4 |
use strict; |
use strict; |
5 |
|
|
6 |
use Carp qw/confess/; |
use Carp qw/confess/; |
7 |
|
use Data::Dump qw/dump/; |
8 |
|
|
9 |
=head1 NAME |
=head1 NAME |
10 |
|
|
11 |
WebPAC::Output - The great new WebPAC::Output! |
WebPAC::Output - The great new WebPAC::Output! |
12 |
|
|
|
=head1 VERSION |
|
|
|
|
|
Version 0.01 |
|
|
|
|
13 |
=cut |
=cut |
14 |
|
|
|
our $VERSION = '0.01'; |
|
|
|
|
15 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
16 |
|
|
17 |
Common routines for output formats |
Common routines for output formats |
21 |
=head2 ds_to_hash |
=head2 ds_to_hash |
22 |
|
|
23 |
my $hash = $self->ds_to_hash( $ds, 'display' |
my $hash = $self->ds_to_hash( $ds, 'display' |
24 |
disable_key_mungle => 1, |
disable_key_mungle => 0, |
25 |
|
singe_values = 0, |
26 |
); |
); |
27 |
|
|
28 |
=cut |
=cut |
44 |
$name =~ s/\W+/_/g; |
$name =~ s/\W+/_/g; |
45 |
} |
} |
46 |
|
|
47 |
|
my $v = $ds->{$t} || die "bug"; |
48 |
|
|
49 |
# FIXME get rid of non hash values in data_structure for consistency? |
# FIXME get rid of non hash values in data_structure for consistency? |
50 |
next unless ref($ds->{$t}) eq 'HASH'; |
next unless ref($v) eq 'HASH'; |
51 |
|
|
52 |
if ( defined( $ds->{$t}->{$type} ) ) { |
if ( defined( $v->{$type} ) ) { |
53 |
$hash->{$name} = $ds->{$t}->{$type}; |
if ( $opt->{single_values} && ref($v->{$type}) eq 'ARRAY' ) { |
54 |
|
$hash->{$name} = join(' ', map { |
55 |
|
if(ref($_)) { |
56 |
|
dump($_); |
57 |
|
} else { |
58 |
|
$_; |
59 |
|
} |
60 |
|
} @{ $v->{$type} }); |
61 |
|
} else { |
62 |
|
$hash->{$name} = $v->{$type}; |
63 |
|
} |
64 |
} |
} |
65 |
} |
} |
66 |
|
|