column value comparison in a file

Hi,

Can any one help with my below requirement.

i need to compare each line by line and in each line i have to compare some columns values with previous line column values in perl script.

Can any one help me........! its very urgent.

Thanks

Please show sample input and desired output for us to get the exact idea about your problem.

Please see my below sample file

M000001866|SN74LS147DR2|9.9|1.75|1.27|DUAL|70|0|5.25|4.75|5|33|9|
M000001866|SN74LS147DR2|9.9|1.75|1.27|DUAL|70|0|5.25|4.75|5|31|9|
M000005010|HCS283K/SAMPLE||||DUAL|||5.5|4.5|5|62|4|
M000005010|HCS283K/SAMPLE||||DUAL|||5.5|4.5|5|40|4|

in this if u see -f1 it has M000001866 in 1,2 lines and in the last but one column for the first line we hav 33 and in 2nd line we have 31

if this column has a different value compare to previous line same column it as show the flag as CHANGED at the end of the line.

My first question is, does this file contain 2 entries for each id(e.g. M000001866)?? I mean is this file identical?

I m assuming the answer yes for this question. Also, I guess u have opened this file in your perl script and reading line by line.

open FF, "</path/file";
    my $lastid = "";
    my $lastvalue = 0;
    while (<FF>) {
        chomp $_;
        my ($id, $value) = (split /|/, $_)[0,11];
        if ($id eq $lastid) {
            my $diff = $value - $lastvalue;
            print "DIFF OF $id = [".$diff."]\n" if ($diff != 0);
        }
        $lastid = $id;
        $lastvalue = $value;
    }
close FF;