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; |
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 |
|
|