| Hash::Work - Several static functions to manipulate hash-arrays |
Hash::Work - Several static functions to manipulate hash-arrays
# exports all functions use Hash::Work ':all';
# E.g. a specific function use Hash::Work qw/merge_hashes/;
This class provides several static methods to manipulate hashes. Some of this methods you can also find in different modules, but I wanted to provide a simplier way to import that methods to a class.
Exporter
Clone
5.006
my \%hashref = array_to_hash(@array | \@arrayref);
Converts simply an array to a hash by using the array entries as key and a 1 as value. Returns context specific a reference to a hash or a hash.
copy_hash_values(\%from, \%to);
copy the hash values from first hash to the second.
first_arrays_to_hash();
removes arrays from a hash recursively by taking first array entry.
example:
input:
$VAR1 = {
'anode' => [
{
'name' => 'anything',
'abc' => [
{
'foo' => [
'text'
]
}
]
}
]
};
output:
$VAR1 = {
'anode' => {
'name' => 'anything',
'abc' => {
'foo' => 'text'
}
}
};
I use it to handle some results of XML::Simple, to flaten it.
merge_hashes();
takes 2 hashes and merges them by using their keys to one hash. returns a hash or hashref, depending on the context call. It uses the Hash::Merge class.
Andreas Hernitscheck ahernit(AT)cpan.org
You can redistribute it and/or modify it under the conditions of LGPL.
| Hash::Work - Several static functions to manipulate hash-arrays |