--- venkateshwar <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I have a large set of values like this in two
> different columns,both
> the values are variables..
> 
> 
> I need to check if first value(ValA) is same in any
> of the
> consecutive
> values and then find the difference between valB of
> those two matched
> valA! and the next instant the difference should be
> between the valB
> of second one with third match.
> 
> 
> For example in this set, 9 appears thrice. first
> time, the difference
> shd be printed as 3099  - 3000, the next time, it
> should be printed
> as
> 5098 - 3099.
> 
> 
> valA,valB
> 9,3000
> 10,3010
> 1,3011
> 2,1020
> 3,3001
> 4,4010
> 9,3099
> 5,4011
> 18,4020
> 19,2044
> 20,3098
> 9,5098
> 
> 
> How do I do this in Perl??
> 
> 

Hi,

Using hash.see this sample:

open FILE,"yourfile" or die $!;
my %hash;
while(<FILE>) {
    chomp;
    my ($v1,$v2)=split/,/;
    print $v1," : ",$v2," - ",$hash{$v1},"\n" if
exists $hash{$v1};
    $hash{$v1} = $v2;
}
close FILE;


       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to