On 8/27/07, Chas Owens <[EMAIL PROTECTED]> wrote:
>
> On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
> snip
> > > > my %prefix_to_rate = (
> > > >         12   => 0.30,
> > > >         1234 => 0.35,
> > > >         134  => 0.50,
> > > >         44   => 0.70
> > > > );
> snip
> > my %prefix_to_rate = (
> >        '+12'   =>0.30,
> >        '+1234' =>0.35,
> >        '+134'  =>0.50,
> >        '+44'   =>0.70
> > );
> snip
> >                     my $key = substr $cdr[3], 1, $len;
> snip
>
> Your substr should use 0 instead of 1.  If you look back at my example
> you can see that the string the corresponds to your $cdr[3] had + at
> the start, but my keys did not.  This is because I was using an offset
> of 1 which is the second character (i.e. the character after the +).
>
Hi,

Still same result...

Look at the following:-

if (defined $rate) {
                        print $OUT_FILE "found rate","\n" ;
                        print $OUT_FILE "the rate for $cdr[3] is $rate: ",
($cdr[6]/20)*$rate , "\n";
                }
                        else
                        {
                                print $OUT_FILE "$cdr[3] does not have a
rate\n";
                }

Even if my $cdr[3] field in few of the records matches with the keys in the
hash, it is still not going to the if part at all.
It just takes one of the not matching records and printing the else part in
the $OUT_FILE.

OUT_FILE content:-
+60199479787 does not have a rate

Any idea?

Thanks,
Mihir

Reply via email to