/[webpac2]/trunk/lib/WebPAC/Common.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/Common.pm

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

revision 923 by dpavlin, Mon Sep 3 15:26:46 2007 UTC revision 924 by dpavlin, Wed Oct 31 00:26:45 2007 UTC
# Line 1  Line 1 
1  package WebPAC::Common;  package WebPAC::Common;
2    use Exporter 'import';
3    @EXPORT = qw/
4            force_array
5    /;
6    
7  use warnings;  use warnings;
8  use strict;  use strict;
# Line 169  sub var_path { Line 173  sub var_path {
173          return File::Spec->catfile('var', @_);          return File::Spec->catfile('var', @_);
174  }  }
175    
176    =head1 EXPORTED NETHODS
177    
178    =head2 force_array
179    
180      my @array = force_array( $ref, sub {
181            warn "reference is undefined!";
182      });
183    
184    =cut
185    
186    sub force_array {
187            my ( $what, $error ) = @_;
188            my @result;
189            if ( ref( $what ) eq 'ARRAY' ) {
190                    @result = @{ $what };
191            } elsif ( defined $what ) {
192                    @result =  ( $what );
193            } else {
194                    $error->() if ref($error) eq 'CODE';
195            }
196            return @result;
197    }
198    
199    
200  =head1 INTERNAL METHODS  =head1 INTERNAL METHODS
201    

Legend:
Removed from v.923  
changed lines
  Added in v.924

  ViewVC Help
Powered by ViewVC 1.1.26