Click to See Complete Forum and Search --> : Help counting entries.


buggy
09-22-2004, 06:05 AM
Firstly I just know this is something basic, I just have a feeling but I cant get it to work. I have a info.txt file in which I have written info extracted from html pages into. The file is like this:

page1.html Company : AAA
page1.html Salary : £2222 per year

page1.html Company : BBB
page1.html Salary : £2222

page1.html Company : CCC
page1.html Salary :

page2.html Company : XXX
page2.html Salary : 1454

page2.html Company : XXX
page2.html Salary : neg


and so on.

Firstly I want to get the number of companies so I can say "x company entries have been found. I have used

@fileinfo[$mycount] =~ m|\s*page[\d+]\.html\s*Company\s*\:\s*[\d+\w+\:\']|i;

with no success.

On the salary I need to find a match also as I want to say "x amount of jobs have salaries."

However I also want to try and match the case where no salary is present and am having problems

eg. page1.html Salary :

Any help would be great.

Jona
09-22-2004, 10:01 AM
I would check each line for something like the following.


$jobs = 0;
open ("FILE", "<info.txt");
if(<FILE> =~ s/page\d\.html Salary \: .*/i){
$jobs++;
}