Callsign/Base.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 57 CC 4 SCAR 23.0
CC
4
Cov
0%
read_config
20.0
new
2.0
init
2.0
CRAP 10.0
1 # Copyright (C) 2008 Wes Hardaker
2 # License: Same as perl. See the LICENSE file for details.
3 package Ham::Callsign::Base;
4  
5 require Exporter;
6 our @ISA = qw(Exporter);
7 our @EXPORT = qw(Warn Debug);
8  
9 sub new {
10 my $type = shift;
11 my ($class) = ref($type) || $type;
12 my $self = {};
13 %$self = @_;
14 bless($self, $class);
15 $self->read_config();
16 $self->init();
17 return $self;
18 }
19  
20 sub init {
21 # noop .. overridden by other clasess when needed
22 }
23  
24 sub read_config {
25 my $self = shift;
26 my $configfile = $self->{'callsignrc'} || $ENV{'CALLSIGNRC'} ||
27 $ENV{'HOME'} . "/.callsignrc";
28 return if (! -f $configfile);
29 Debug("reading $configfile\n");
30 open(I,$configfile);
31 while (<I>) {
32 next if (/^\s*#/);
33 if (/^([^:]+):\s*(.*)/) {
34 $self->{$1} = $2;
35 }
36 }
37 close(I);
38 }
39  
40 sub Warn {
41 warn @_;
42 }
43  
44 sub Debug {
45 return;
46 print @_;
47 }
48  
49 1;