www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > Perl

    Perl Discussion and technical support for using and deploying Perl.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 09-22-2004, 06:05 AM
    buggy buggy is offline
    Registered User
     
    Join Date: Aug 2004
    Posts: 46
    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.
    Reply With Quote
      #2  
    Old 09-22-2004, 10:01 AM
    Jona's Avatar
    Jona Jona is offline
    Stuper Murderator
     
    Join Date: Jan 2003
    Location: Texas
    Posts: 10,537
    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++;
     }
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:56 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.