bh_perl has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w my $template = "A12 A4 A20 A20 A2 A2 A2 A2 A12 A4 A24 A24"; my %bcodedb = (); while (<>) { my $input = $_; my @a = unpack($template, $input); my $anum = substr($a[2], skip_zero($a[2])); my $bnum = substr($a[3], skip_zero($a[3])); open (F, "cat mnta2/bmp/table/smsc/chg_indicator.hdb |"); while (<F>) { chomp; next if $_ =~ /^#/; my ($ano, $bno, $bcode) = split(/,/); if ($anum =~ /$ano/ && $bnum =~ /$bno/) { $bcode->{ count }++; if ( defined $bcodedb{$bcode} ) { next; } else { $bcodedb{$bcode} = "BCODE"; } last; } } close (F); } while ( my ($l, $k) = sort each(%bcodedb) ) { my $a = $l->{ count } || 0; print "Total calls for Billing Code [$l] : $a \n"; } sub skip_zero { my ($a) = @_; my $j = 0; foreach my $i (split //, $a) { return $j if ($i > 0); $j++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simplifying my script...
by Fletch (Bishop) on Apr 24, 2004 at 21:06 UTC | |
|
Re: Simplifying my script...
by matija (Priest) on Apr 24, 2004 at 21:40 UTC | |
by u235sentinel (Hermit) on Apr 25, 2004 at 02:14 UTC | |
by matija (Priest) on Apr 25, 2004 at 06:10 UTC | |
|
Re: Simplifying my script...
by tkil (Monk) on Apr 25, 2004 at 20:53 UTC |