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 6852913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:26:55+00:00 2026-05-27T01:26:55+00:00

All, I realise against gooogle ToC but I was trying to write a perl

  • 0

All,
I realise against gooogle ToC but I was trying to write a perl script that performs a google search and returns the number of hits (eg the 1 of about XXXX for search term). I should state I am perl newbie.

After reading etc this is what I have but it does not return any thing and I’m not sure why…can anyone give me some pointers.

use LWP::Simple;

my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0');

my $url=$ARGV[0];
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);

$res->content;  

print "all done \n";    

while ($res ==~ /of about <b>([1234567890,]<\/b> +)/) {
  print $res;
}
  • 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-05-27T01:26:55+00:00Added an answer on May 27, 2026 at 1:26 am

    The line:

    while ($res ==~ /of about <b>([1234567890,]<\/b> +)/) {
    

    Has the following errors:

    • While statement will cause an endless loop if the string matches,
      because…
    • …the regex lacks the /g global option, which would be useless
      because…
    • …I assume this match will happen only once.
    • [1234567890,] will only match one character, and is better written
      [0-9,]+. Note the plus sign at the end to allow multiple matches.
    • ==~ should be =~
    • $res should probably be $res->content, like a’r stated in the
      comment.
    • Your capture group extends beyond the </b> tag, which I suppose is
      a typo?

    Also, you print out the whole $res object, when you probably only want to print the number.
    More correct version:

    if ($res->content =~ /of about <b>([0-9,]+)/) { print $1 }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

all. We're trying to get some intersect collisions working, but the problem experience is
We all write code with some patterns even when we dont realise it. I
When dealing with keyboard event, I realise that not all element can get the
First of all, I realise fully that this question has been asked numerous times,
I'm trying to write a function that will dump a recursive tree of window
So Heroku has been down all day, of course I didn't realise this until
I've realised that there is more levels than all, debug, info, warn, error and
It seems like Windows 8 is all about developers. But I didn't realize a
All I want to do is return the index of the i that is
I've spent all day Googling and looking at various questions on here, trying to

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.