File Coverage

blib/lib/Tie/Hash/Identity.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Tie::Hash::Identity;
2              
3 2     2   33442 use warnings;
  2         6  
  2         82  
4 2     2   12 use strict;
  2         6  
  2         574  
5              
6             =head1 NAME
7              
8             Tie::Hash::Identity - A hash that always returns the key
9              
10             =head1 VERSION
11              
12             Version 0.01
13              
14             =cut
15              
16             our $VERSION = '0.01';
17              
18             =head1 SYNOPSIS
19              
20             use Tie::Hash::Identity;
21              
22             my %hash;
23             tie %hash, 'Tie::Hash::Identity';
24              
25             $hash{abc} eq 'abc'; # true
26             $hash{1+2+3} eq '6'; # true
27              
28             =head1 DESCRIPTION
29              
30             A hash that always returns the key.
31              
32             It's useful when interpolating EXPR in a double quoted string.
33              
34             Maybe you should try Hash::Identity with a better importing interface.
35              
36             It only support for retrieving data. Never storing data back, nor trying to iterate over it.
37              
38             =cut
39              
40             sub TIEHASH {
41 1     1   832 bless {}, $_[0]
42             }
43              
44             sub FETCH {
45 3     3   1156 $_[1]
46             }
47              
48             =head1 SEE ALSO
49              
50             L - same thing, with a better importing interface.
51              
52             =head1 AUTHOR
53              
54             Cindy Wang (CindyLinz)
55              
56             =head1 BUGS
57              
58             Please report any bugs or feature requests to C, or through
59             the web interface at L. I will be notified, and then you'll
60             automatically be notified of progress on your bug as I make changes.
61              
62             =head1 LICENSE AND COPYRIGHT
63              
64             Copyright 2010 Cindy Wang (CindyLinz).
65              
66             This program is free software; you can redistribute it and/or modify it
67             under the terms of either: the GNU General Public License as published
68             by the Free Software Foundation; or the Artistic License.
69              
70             See http://dev.perl.org/licenses/ for more information.
71              
72              
73             =cut
74              
75             1; # End of Tie::Hash::Identity