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