Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:34:58+00:00 2026-06-15T17:34:58+00:00

I am trying to do a screen scrape in perl and have it down

  • 0

I am trying to do a screen scrape in perl and have it down to a array of table elements.

the string:

<tr>
        <td>10:11:00</td>
        <td><a href="/page/controller/33">712</a></td>
        <td>Start</td>
        <td>Finish</td>
        <td>200</td>
        <td>44</td>

Code:

if($item =~ /<td>(.*)?<\/td>/)
            {
                print "\t$item\n";
                print "\t1: $1\n";
                print "\t2: $2\n";
                print "\t3: $3\n";
                print "\t4: $4\n";
                print "\t5: $5\n";
                print "\t6: $6\n";
            }

output:

1: 10:11:00
2: 
3: 
4: 
5: 
6: 

I tried multiple thing but could not get the intended results. thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:34:59+00:00Added an answer on June 15, 2026 at 5:34 pm

    The code behaves exactly as you told it to. This is what happens:

    You matched the regex exactly once. It did match, and populated the $1 variable with the value of the first (and only!) capture buffer. The match returns “true”, and the code in the if-branch is executed.

    You want to do two things:

    1. Match with the /g modifier. This matches globally, and tries to return every match in the string, not just the first one.
    2. Execute the regex in list context, so you can save the capture buffers to an array

    This would lead to the following code:

    if ( my @matches = ($item =~ /REGEX/g) ) {
      for my $i (1 .. @matches) {
        print "$i: $matches[$i-1]\n";
      }
    }
    

    Do also note that parsing HTML with regexes is evil, and you should search CPAN for a module you like that does that for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to screen- scrape a html page so I can extract desired
I am currently trying to do a screen scrape using the following code: HttpWebRequest
I am trying to screen scrape values from a website. # get the raw
I am trying to screen scrape using C#.It works for few times,after which i
i'm trying to get the html of a page using this screen scraping in
OK, this is driving me nuts. I'm trying to screen-scrape the following bit of
Trying to have more than 1 alv grid on my screen, and trying to
I have a site that I screen-scrape off GoogleMaps to get the driving distance
I'm trying to do a screen scrape using jquery in a PhoneGap application. The
I've been online trying to find examples of how to screen scrape and or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.