line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Merge::HashRef; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Merge::HashRef::VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use base 'Exporter::Simple'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
942
|
|
9
|
|
|
|
|
|
|
use Carp; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Merge::HashRef - make one hashref out of many! |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Merge::HashRef; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $hashref = merge_hashref($ref1, $ref2, ...) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Recently, I found myself turning lots of hashrefs into a single one. |
24
|
|
|
|
|
|
|
And, I thought, this would be a nice little function to have. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
So now you have it too! |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 merge_hashref |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $hashref = merge_hashref($ref1, $ref2, ...) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This takes a list of hashrefs, and returns you one. Of course, the order |
33
|
|
|
|
|
|
|
you pass your hashrefs in IS important, as later key/value pairs will |
34
|
|
|
|
|
|
|
clobber earlier ones. This is deliberate. This is why I wrote this little |
35
|
|
|
|
|
|
|
module! |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
All non-hashrefs get removed from the passed-in list. So don't be doing that. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub merge_hashref : Exported { return { map %$_, grep ref $_ eq 'HASH', @_ } } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SHOWING YOUR APPRECIATION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
There was a thread on london.pm mailing list about working |
47
|
|
|
|
|
|
|
in a vacumn - that it was a bit depressing to keep writing |
48
|
|
|
|
|
|
|
modules but never get any feedback. So, if you use and |
49
|
|
|
|
|
|
|
like this module then please send me an email and make my |
50
|
|
|
|
|
|
|
day. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
All it takes is a few little bytes. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
(Leon wrote that, not me!) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Stray Toaster, Ecoder@stray-toaster.co.ukE |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Copyright 2002 by Stray Toaster |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
65
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |