Abbrev/Smart.pm

filter: Statementstmt 100% 16 / 16 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 86.2% 25 / 29 CC 3 SCAR 6.7
CC
3
Cov
90%
equals
3.2
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Array.pm ↑ Summary
1 package Tie::Hash::Abbrev::Smart;
2  
3 =head1 NAME
4  
5 Tie::Hash::Abbrev::Smart - a hash which can be accessed using abbreviated keys
6  
7 =head1 SYNOPSIS
8  
9 use Tie::Hash::Abbrev::Smart;
10  
11 tie my %hash, 'Tie::Hash::Abbrev::Smart';
12  
13 %hash = ( sonntag =>0, montag =>1, dienstag=>2, mittwoch =>3,
14 donnerstag=>4, freitag=>5, samstag =>6,
15 sunday =>0, monday =>1, tuesday =>2, wednesday=>3,
16 thursday =>4, friday =>5, saturday=>6 );
17  
18 print $hash{do}; # will print "4"
19 print $hash{fr}; # will print "5"
20 print $hash{t}; # undef
21  
22 my @deleted = tied(%hash)->delete_abbrev(qw(do fr t));
23 # will delete elements "donnerstag", "freitag" and "friday";
24 @deleted will be (4,5,5)
25  
26 =head1 DESCRIPTION
27  
28 This module implements a subclass of L<Tie::Hash::Abbrev>.
29 The contents of hashes tied to this class may be accessed via unambiguously
30 abbreviated keys.
31 (Please note, however, that this is not true for
32 L<deleting|perlfunc/"delete EXPR"> hash elements;
33 for that you can use L<Tie::Hash::Abbrev/delete_abbrev()> via the object
34 interface.)
35  
36 In contrast to L<Tie::Hash::Abbrev>, an abbreviation is still considered to be
37 unambiguous even if more than one key starting with the respective string
38 exists, as long as all of the corresponding elements have identical (string)
39 values.
40  
41 =head1 BUGS
42  
43 None known so far.
44  
45 =head1 AUTHOR
46  
47 Martin H. Sluka
48 mailto:perl@sluka.de
49 http://martin.sluka.de/
50  
51 =head1 COPYRIGHT
52  
53 This program is free software; you can redistribute
54 it and/or modify it under the same terms as Perl itself.
55  
56 The full text of the license can be found in the
57 LICENSE file included with this module.
58  
59 =head1 SEE ALSO
60  
61 L<Tie::Hash::Abbrev>
62  
63 =cut
64  
65 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
67 2 ▶use Tie::Hash::Abbrev; # for buggy base.pm in Perl 5.005_03
Subroutine BEGIN: called CC=1 SCAR=0.0
68 2 ▶use base 'Tie::Hash::Abbrev';
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70 2 $VERSION = 0.01;
71  
72 49 ▶sub equals {
Subroutine equals: called CC=3 SCAR=11.7
Pod undocumented
73 49 my ( $self, $value0, $value1 ) = @_;
74 49 ▶ defined $value0 ? defined $value1 && $value0 eq $value1 : !defined $value1;
Branch: 1 branch
BranchTrueFalseTotal
defined $value0 ? : 49 0 49
Condition66%2/3
defined $value1 and $value0 eq $value1
!ll&&!rl&&r
01435
MC/DC50%1/2
defined $value1 and $value0 eq $value1
defined $value1 $value0 eq $value1
Truth table66%2/3
A and B
A= defined $value1B= $value0 eq $value1
ABresult
0X0
100
111
75 }
76  
77 2 1
« Array.pm ↑ Summary