|
|||||||
| Perl Discussion and technical support for using and deploying Perl. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help counting entries.
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. Last edited by buggy; 09-22-2004 at 06:08 AM. |
|
#2
|
||||
|
||||
|
I would check each line for something like the following.
Code:
$jobs = 0;
open ("FILE", "<info.txt");
if(<FILE> =~ s/page\d\.html Salary \: .*/i){
$jobs++;
}
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|