Expr/TypeDB.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 44 CC 4 SCAR 24.0
CC
4
Cov
0%
Load
20.0
new
2.0
Keys
2.0
CRAP 11.0
1 #!/usr/bin/perl
2  
3 # TypeDB.pm - A db of basic types and there properties
4 # (c) Copyright 1998 Hakan Ardo <hakan@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  
20 =head1 NAME
21  
22 Math::Expr::TypeDB - A db of basic type and there properties
23  
24 =head1 SYNOPSIS
25  
26 require Math::Expr::TypeDB;
27 $db=new Math::Expr::TypeDB($file);
28  
29 =cut
30  
31 package Math::Expr::TypeDB;
32 use strict;
33  
34 sub new {
35 my $self = bless {}, shift;
36 $self->Load(shift);
37 $self;
38 }
39  
40 sub Load {
41 my ($self, $file) = @_;
42 my %t;
43  
44 open (F, "<$file");
45 while (<F>) {
46 if (/^([^:]+)\s*:\s*(.*)$/) {$t{lc($1)}=$2;}
47 if (/^\s*$/ || eof F) {
48 if ($t{'name'}) {
49 my $t=$t{'name'};
50 delete $t{'name'};
51  
52 foreach (keys %t) {
53 $self->{'opps'}{$t}{$_}=$t{$_};
54 delete $t{$_};
55 }
56 }
57 }
58 }
59 }
60  
61  
62 sub Keys {
63 my $self = shift;
64  
65 keys %{$self->{'opps'}};
66 }
67  
68 sub Get {
69 my ($self, $a) = @_;
70  
71 $self->{'opps'}{$a};
72 }
73  
74 1;