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

  • Home
  • SEARCH
  • 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 802951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:40:50+00:00 2026-05-14T23:40:50+00:00

How do I do the following in Perl in order: a) curl a page

  • 0

How do I do the following in Perl in order:
a) curl a page and save it to a variable
b) parse the value of the variable (which is HTML content) for values I want (ex: the info is kept between tags like … )

  • 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-14T23:40:50+00:00Added an answer on May 14, 2026 at 11:40 pm

    My perl kung-fu is rusty, but I believe it’s something along following lines.

    To fetch something using curl and then extract for example contents of some html element:

    use WWW::Curl::Easy;
    my $curl = new WWW::Curl::Easy;
    $curl->setopt(CURLOPT_URL, 'http://www.example.com/some-url.html');
    open (my $fileb, ">", \$response_body);
    $curl->setopt(CURLOPT_WRITEDATA, $fileb);
    $curl->perform;
    my $info = $curl->getinfo(CURLINFO_HTTP_CODE);
    
    $response_body =~ m|<a[^>]+>(.+?)</a>|;
    

    Now, $1 should contain contents of A element. If it doesn’t, it will say that $1 is undefined or something similar. You should first check in $info that status code is as expected, of course. This being Perl code, it’s ugly this way, but it works. However, I recommend not doing this often (and especially not in bigger scripts), as it’s certainly fastest road to shooting yourself in the foot with Perl:

    You shoot yourself in the foot, but nobody can understand how you did it. Six months later, neither can you.

    I hope it helps.

    P.S. I am sure that there is some easier way around, without this much code, but I can’t remember how it goes…

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

Sidebar

Related Questions

I have the following perl script: $myVariable = some value; //... some code ...
I wrote the following Perl script (below) in order to create simple XML file.
in my little perl script (test.pl) I do the following in order to exit
I've got the following Perl code which makes a DBI call: my $artsql =
I am using the Following Perl code to parse an array in JSON, using
Assume that the following Perl code is given: my $user_supplied_string = &retrieved_from_untrusted_user(); $user_supplied_string =~
I have to maintain the following Perl script: #!/usr/bin/perl -w die Usage: $0 <file1>
What does the colon mean in the following Perl program? MAIN: { print Hello\n;
I'm trying to clean up form input using the following Perl transliteration: sub ValidateInput
I need to do mimic the functionality of the following Perl code if($file =~

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.