#!/usr/bin/perl
# - set up the list
@items = (
"1Mb network card",
"10Mb network card",
"100Mb network card",
"1Mb network card",
"Laptop",
"Monitor",
"Laptop",
);
# - here's the magic
foreach $item (@items) {
$qty{$item}++;
}
# - print them out
foreach $item (sort keys %qty) {
$quantity=$qty{$item};
$quantity=sprintf("%02d",$quantity);
print "($quantity) $item\n";
}
-----Original Message-----
From: Ruebel Oliver [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 21, 2001 3:13 AM
To: [EMAIL PROTECTED]
Subject: Pattern Matching
How can I get through pattern matching an operation that, if there a two similar lines (I�m searching for) the program counts them and gives me only one line output with the number of hits in front.
Like when the program founds 2 lines with:
Network Interface Card 10 Mbit
Network Interface Card 10 Mbit
It gives me the output:
2 Network Interface Card 10 Mbit
Thanks in advance!
