1 |
package WebPAC::Output; |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use Carp qw/confess/; |
7 |
|
8 |
=head1 NAME |
9 |
|
10 |
WebPAC::Output - The great new WebPAC::Output! |
11 |
|
12 |
=head1 VERSION |
13 |
|
14 |
Version 0.01 |
15 |
|
16 |
=cut |
17 |
|
18 |
our $VERSION = '0.01'; |
19 |
|
20 |
=head1 SYNOPSIS |
21 |
|
22 |
Common routines for output formats |
23 |
|
24 |
=head1 FUNCTIONS |
25 |
|
26 |
=head2 ds_to_hash |
27 |
|
28 |
my $hash = $self->ds_to_hash( $ds, 'display' ); |
29 |
|
30 |
=cut |
31 |
|
32 |
sub ds_to_hash { |
33 |
my $self = shift; |
34 |
|
35 |
my ( $ds, $type ) = @_; |
36 |
|
37 |
confess "need ds" unless $ds; |
38 |
confess "need type" unless $type; |
39 |
|
40 |
my $hash; |
41 |
|
42 |
foreach my $t ( keys %$ds ) { |
43 |
my $name = lc($t); |
44 |
$name =~ s/\W+/_/g; |
45 |
|
46 |
# FIXME get rid of non hash values in data_structure for consistency? |
47 |
next unless ref($ds->{$t}) eq 'HASH'; |
48 |
|
49 |
if ( defined( $ds->{$t}->{$type} ) ) { |
50 |
$hash->{$name} = $ds->{$t}->{$type}; |
51 |
} |
52 |
} |
53 |
|
54 |
return $hash; |
55 |
} |
56 |
|
57 |
=head1 AUTHOR |
58 |
|
59 |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
60 |
|
61 |
=head1 COPYRIGHT & LICENSE |
62 |
|
63 |
Copyright 2005-2007 Dobrica Pavlinusic, All Rights Reserved. |
64 |
|
65 |
This program is free software; you can redistribute it and/or modify it |
66 |
under the same terms as Perl itself. |
67 |
|
68 |
=cut |
69 |
|
70 |
1; # End of WebPAC::Output |