/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15 by dpavlin, Sun Jul 17 10:42:23 2005 UTC revision 1069 by dpavlin, Tue Nov 27 23:54:43 2007 UTC
# Line 3  package WebPAC::Output; Line 3  package WebPAC::Output;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    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  Quick summary of what the module does.  Common routines for output formats
18    
19  Perhaps a little code snippet.  =head1 FUNCTIONS
20    
21      use WebPAC::Output;  =head2 ds_to_hash
22    
23      my $foo = WebPAC::Output->new();    my $hash = $self->ds_to_hash( $ds, 'display'
24      ...          disable_key_mungle => 0,
25            singe_values = 0,
26      );
27    
28  =head1 EXPORT  =cut
29    
30  A list of functions that can be exported.  You can delete this section  sub ds_to_hash {
31  if you don't export anything, such as for a purely object-oriented module.          my $self = shift;
32    
33  =head1 FUNCTIONS          my $ds = shift || confess "need ds";
34            my $type = shift || confess "need type";
35    
36  =head2 function1          my $opt = {@_};
37    
38  =cut          my $hash;
39    
40            foreach my $t ( keys %$ds ) {
41                    my $name = $t;
42                    if ( ! $opt->{disable_key_mungle} ) {
43                            $name = lc($name);
44                            $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?
50                    next unless ref($v) eq 'HASH';
51    
52                    if ( defined( $v->{$type} ) ) {
53                            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    
67  sub function1 {          return $hash;
68  }  }
69    
 =head2 function2  
   
 =cut  
   
 sub function2 {  
 }  
70    
71  =head1 AUTHOR  =head1 AUTHOR
72    
# Line 53  Dobrica Pavlinusic, C<< <dpavlin@rot13.o Line 74  Dobrica Pavlinusic, C<< <dpavlin@rot13.o
74    
75  =head1 COPYRIGHT & LICENSE  =head1 COPYRIGHT & LICENSE
76    
77  Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.  Copyright 2005-2007 Dobrica Pavlinusic, All Rights Reserved.
78    
79  This program is free software; you can redistribute it and/or modify it  This program is free software; you can redistribute it and/or modify it
80  under the same terms as Perl itself.  under the same terms as Perl itself.

Legend:
Removed from v.15  
changed lines
  Added in v.1069

  ViewVC Help
Powered by ViewVC 1.1.26