in reply to Some Basic Help.
while (my $train = <trained>) { while (my $predict = <predict>) { ... } seek predict, 0, 0; // need to return to the start of the predict fil +e!!! }
Also, the condition is wrong! It should be if ($train == $predict) if you want to compare numbers or if ($train eq $predict) if you want to compare strings. Perl is happy to convert values from one form to the other, but you have to tell it which one you want. Also in case the files contained floating point numbers the comparison using == would most probably not "work". The two numbers would have to be absolutely equal which is (also due to limited precision computation) very unlikely. You will want to test whether they are within a certain range from each other instead.
You may also want to consider reading the files just once. Choose the smaller one, read it into an array or hash (as you seem to want to test for equality a hash would work better) and then read the other file and check whether the value is present in the array/hash.
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Some Basic Help.
by invaderzard (Acolyte) on Sep 25, 2012 at 07:14 UTC | |
by Jenda (Abbot) on Sep 25, 2012 at 08:06 UTC | |
by invaderzard (Acolyte) on Sep 25, 2012 at 08:35 UTC | |
by Jenda (Abbot) on Sep 25, 2012 at 13:12 UTC | |
by invaderzard (Acolyte) on Sep 25, 2012 at 13:34 UTC |