[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Puzzle - Can you find the bug faster than I did?



At 11:50 PM 6/30/99 -0700, Vicki Brown wrote:
>The input data file looked like:
>
>g1840610        417     417     { 1-417 }       Initial 1.3
>g1840611        1       1       { 1-1 } Initial 1.3
>g1840611        1       1       { 1-1 } Length  1.3
>g1840611        1       1       { 1-1 } Removed 1.3
>g1840612        421     421     { 1-421 }       Initial 1.3
>
>The idea is to read (and print) each line until you come to one with a
>new ID (e.g. g1840610), then insert a new entry between the last line of the
>previous ID's data and the first line of the new ID's data and
>continue on.
>
>I had been trying to track down why the code didn't seem to be working.
>Nothing was being added to the log file and my traces were printing
>"part of same ID" every time.
>             ($field1,$rest) = split(/\t/);
>         trace(1, "found $field1\n");
>             if (($field1 == $prev_clone) || ($i == 1)) {
>Do you see the bug?

Maybe I'm just sensitive to this one, but I spotted it right away.  == 
instead of eq, and it fails because Perl stops at the first thing in the 
string that isn't a number and returns what it has so far, which in this 
case means everything is 0.

>(When I found it, it took me much too long to see it, considering)
>
>HINT: The previous data values looked like this
>
>7500123N        417     417     { 1-417 }       Initial 1.3

Didn't you get a "not numeric in ==" warning?



==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org