sub logtime {
my( $oref, $freecall, $voicemail, $osname, $dur, $bnum ) = @_;
$oref->{ totaldur }{ $osname } += $dur;
$oref->{ totalcdr }{ $osname }++;
if( defined $freecall->{ $bnum } ) {
$oref->{ freedur }{ $osname } += $dur;
$oref->{ freecdr }{ $osname }++;
}
elsif( defined $voicemail->{ $bnum } ) {
$oref->{ voicedur }{ $osname } += $dur;
$oref->{ voicedcr }{ $osname }++;
}
}
my( %o, %freecall, %voicemail, $osname, $dur, $bnum );
# Init with all known osnames.
@o{ qw[ INTIM TOUCH ... ] } = ();
if ( defined $osname{$num1}
and exists $o{ $osname{ $num1 } }
) {
logtime( \%o, \%freecall, \%voicemail
, $osname{ $num1 }, $dur, $bnum );
}
else {
warn 'Undefined or unknown osname';
}
####
my %calls = (
voice => {
123 => undef,
789 => undef,
],
free => {
456 => undef,
],
);
####
my %calls = ( ## Keys are possible $bnum values
123 => 'voice',
456 => 'free',
789 => 'voice',
...
);