PDA

View Full Version : Counting in Flat file database



doester
04-06-2008, 12:36 AM
Hi I'm New here

I have a flat file databse

I use this scrpt to find all lines containg "WON"
It then counts them up and display the count
on a page for me. 1,2,3, etc
-----------------------------------
#!/usr/bin/perl

#My Script
$file = "database.txt";

open(FILE,"$file");
@lines=<FILE>;
close(FILE);

foreach $line (@lines)
{
if ( $line =~ /(WON)/ )
{
$count++;
}

}

print "Content-Type: text/html\n\n";
print "$count";
-----------------------------------

The problem I'm haveing now is I need it to exact match "2 instances"
on (a line) before counting that.

anybody know How I can edit the following to do that?
if ( $line =~ /(WON)/ )

Thanks
Sonny