blib/lib/Tie/Hash/Constant.pm

filter: Statementstmt 100% 13 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 18 / 18 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
TIEHASH
1.0
CRAP 1.0
↑ Summary
1 package Tie::Hash::Constant;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = 0.01;
5  
6 =head1 NAME
7  
8 Tie::Hash::Constant - make a hash return a constant for all its members
9  
10 =head1 SYNOPSIS
11  
12 use Tie::Hash::Constant;
13 tie my %always_pie, 'Tie::Hash::Constant' => 'PIE!';
14 $always_pie{food} = "salad";
15 print "My favourite food is $always_pie{food}\n"; # prints "My favourite food is PIE!"
16 print "There is no $always_pie{spoon}\n"; # prints "There is no PIE!\n"; !!!
17  
18 =head1 DESCRIPTION
19  
20 Tie::Hash::Constant allows you to define a constant to be returned as
21 all values contained within a hash.
22  
23 It has marginal use as a debugging tool.
24  
25 =cut
26  
27 1 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=1 SCAR=0.0
28 1 my $class = shift;
29 1 my $constant = shift;
30 1 return bless \$constant, $class;
31 }
32  
33 2 ▶sub FETCH {
Subroutine FETCH: called CC=1 SCAR=0.0
34 2 my $self = shift;
35 2 return $$self;
36 }
37  
38 1 ▶sub STORE {}
Subroutine STORE: called CC=1 SCAR=0.0
39  
40 1 1;
41 __END__
↑ Summary