/[webpac2]/trunk/lib/WebPAC/Output.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/WebPAC/Output.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 913 - (hide annotations)
Tue Oct 30 20:11:02 2007 UTC (16 years, 6 months ago) by dpavlin
File size: 1076 byte(s)
 r1372@llin:  dpavlin | 2007-10-30 20:26:52 +0100
 first real method in common WebPAC::Output as a move towards pluggable
 outputs

1 dpavlin 1 package WebPAC::Output;
2    
3     use warnings;
4     use strict;
5    
6 dpavlin 913 use Carp qw/confess/;
7    
8 dpavlin 1 =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 dpavlin 913 Common routines for output formats
23 dpavlin 1
24 dpavlin 913 =head1 FUNCTIONS
25 dpavlin 1
26 dpavlin 913 =head2 ds_to_hash
27 dpavlin 1
28 dpavlin 913 my $hash = $self->ds_to_hash( $ds, 'display' );
29 dpavlin 1
30 dpavlin 913 =cut
31 dpavlin 1
32 dpavlin 913 sub ds_to_hash {
33     my $self = shift;
34 dpavlin 1
35 dpavlin 913 my ( $ds, $type ) = @_;
36 dpavlin 1
37 dpavlin 913 confess "need ds" unless $ds;
38     confess "need type" unless $type;
39 dpavlin 1
40 dpavlin 913 my $hash;
41 dpavlin 1
42 dpavlin 913 foreach my $t ( keys %$ds ) {
43     my $name = lc($t);
44     $name =~ s/\W+/_/g;
45 dpavlin 1
46 dpavlin 913 # FIXME get rid of non hash values in data_structure for consistency?
47     next unless ref($ds->{$t}) eq 'HASH';
48 dpavlin 1
49 dpavlin 913 if ( defined( $ds->{$t}->{$type} ) ) {
50     $hash->{$name} = $ds->{$t}->{$type};
51     }
52     }
53 dpavlin 1
54 dpavlin 913 return $hash;
55 dpavlin 1 }
56    
57     =head1 AUTHOR
58    
59     Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
60    
61     =head1 COPYRIGHT & LICENSE
62    
63 dpavlin 913 Copyright 2005-2007 Dobrica Pavlinusic, All Rights Reserved.
64 dpavlin 1
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

  ViewVC Help
Powered by ViewVC 1.1.26