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

How to make selection

From:
WANG, SHIPING [AG/1000]
Date:
January 3, 2002 10:05
Subject:
How to make selection
Message ID:
82136906C193D311976500A0C9EAD048A4A5DB@ems1000-03.monsanto.com
Hi all,

Normally if you want to set condition to select data, do if...and
elsif...(or othet ways). However in my case if I want to only select one
product from each customer based on their category in an order of B, C, A
and D, how can I do that? 

Here is sample data:

__DATA__  
Customer ID:    1711
        * * * No record * * *
Customer ID:    842
        Product ID:     716
        Category:A
        Product ID:     1523
        Category:C
        Product ID:     753
        Category:D
Customer ID:    46917
        Product ID:     20401
        Category:A
        Product ID:     9828
        Category:B
        Product ID:     665
        Category:C
Customer ID:    50
        Product ID:     19554
        Category:D
        Product ID:     4309
        Category:A

What I expect output:

Cust	Prod	Cate
1711
842	1523	C
46917	9828	B
50	4309	A

Thanks in advance.





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About