On 8/27/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: snip > for my $len (reverse $shortest .. $longest) { > my $key = substr $cdr[3],0,$len; > last if $rate = $prefix_to_rate{$key}; > if (defined $rate) { > $cdr[13] =($cdr[6]/20)*$rate ; > } > } snip
The last will execute if $rate is set, so the "if (defined" will never be true (unless rate is 0, which I would assume is an error). You either need to move the "if (defined" outside of the for loop or you need to change the "last if" to if (exists $prefix_to_rate{$key}) { $cdr[13] = $cdr[6]/20*$prefix_to_rate{$key}; last; } Also, you need to work on your indenting. It is all over the place (which is probably why your if statement is in the wrong place). You might consider installing perltidy and running it on your code. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/