all filter can receive array...
|
1 |
package DBIx::Custom::Util; |
2 | ||
3 |
use strict; |
|
4 |
use warnings; |
|
5 | ||
cleanup
|
6 |
sub array_to_hash { |
7 |
my $array = shift; |
|
all filter can receive array...
|
8 |
|
cleanup
|
9 |
return unless $array; |
10 |
return $array if ref $array eq 'HASH'; |
|
all filter can receive array...
|
11 |
|
cleanup
|
12 |
my $hash = {}; |
all filter can receive array...
|
13 |
|
cleanup
|
14 |
for (my $i = 0; $i < @$array; $i += 2) { |
15 |
my $key = $array->[$i]; |
|
16 |
my $f = $array->[$i + 1]; |
|
all filter can receive array...
|
17 |
|
cleanup
|
18 |
if (ref $key eq 'ARRAY') { |
19 |
foreach my $k (@$key) { |
|
20 |
$hash->{$k} = $f; |
|
all filter can receive array...
|
21 |
} |
22 |
} |
|
23 |
else { |
|
cleanup
|
24 |
$hash->{$key} = $f; |
all filter can receive array...
|
25 |
} |
26 |
} |
|
cleanup
|
27 |
return $hash; |
all filter can receive array...
|
28 |
} |
29 | ||
30 |
1; |
|
31 | ||
32 |
=head1 NAME |
|
33 | ||
34 |
DBIx::Custom::Util - Utility class |
|
35 |