develooper Front page | perl.beginners | Postings from March 2002

RE: Can I do this with perl?

Thread Previous | Thread Next
Nikola Janceski
March 4, 2002 07:20
RE: Can I do this with perl?
Message ID:
Yes you can do it with perl, and I suggest using hashes.

open(FILE, "$file");
my %seen;
	my ($item9, $item10) = (split /\|/, $_)[8,9];
	if(exists $seen{$item9}){
		if($itme10 > $seen{$item9}){
			# the new $item10 is larger than the last one seen
			} else {
			# the contrary is true
		} else {
		$seen{$item9} = $itme10;
close FILE;

-----Original Message-----
From: Dave Adams []
Sent: Monday, March 04, 2002 10:10 AM
Subject: Can I do this with perl?

Hi there,

I have a problem which I would like to use perl to resolve, however I'm not
sure if it is possible to do. 

I need to scan a file and check some conditions, first if field 9 is
duplicated on 1 or more rows, then I need to check field 10 to see which is
the greater value and then only print the whole row where field 10 is the
greater, if field 9 is not a duplicate then print the whole row.
An example of the data is below.



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About