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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:55:36+00:00 2026-05-23T21:55:36+00:00

I am trying to extract data from website using Perl API. I am using

  • 0

I am trying to extract data from website using Perl API. I am using a list of URIs to get the data from the website.

Initially the problem was that if there was no data available for the URI it would die and I wanted it to skip that particular URI and go to the next available URI. I used next unless ....; to come over this problem.

Now the problem is I am trying to extract specific data from the web by calling a specific method (called as identifiers()) from the API. Now the data is available for the URI but the specific data (the identifiers), what I am looking for, is not available and it dies.

I tried to use eval{} like this

eval {
    for $bar ($foo->identifiers()){
        #do something
    };
}

When I use eval{} I think it skips the error and moves ahead but I am not sure. Because the error it gives is “Invalid content type in response:text/plain”.

Whereas I checked the URI manually, though it doesn’t have the identifiers it has rest of the data. I want this to skip and move to next URI. How can I do that?

I got a reply from one of the experts that:
When Perl hits an error, like most languages, it runs out through the calling contexts in order until it finds a place where it can handle the error. Perl’s most basic error handling is eval{} (but I’d use Try::Tiny if you can, as it is then clearer that you’re doing error handling instead of some of the other strange things eval can do).
Anyway, when Perl hits eval{}, the whole of eval{} exits, and $& is set to the error. So, having the eval{} outside the loop means errors will leave the loop. If you put the eval{} inside the loop, when an error occurs, eval{} will exit, but you will carry on to the next iteration. It’s that simple.

But really the error I get is invalid content type in response: text/html at mycode line 41 and the line 41 in my code (my program) is really to the data from web. I know there is no error in the code because it works fine for previous uris. Now, how do I fix this error and move ahead to next uri? my program stucks at this error.

  • 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-23T21:55:37+00:00Added an answer on May 23, 2026 at 9:55 pm

    I’m now assuming your code looks something like this:

    while (<IN0>) {
        my $currentURI = $_; 
        chomp($currentURI); 
        my @tags = $c->posts_for(uri =>"$currentURI");
        ... do something ...
    }
    

    To handle errors, safely, use something like this (assuming eval()):

    while (<IN0>) {
        my $currentURI = $_; 
        chomp($currentURI); 
        my @tags = eval {        # Use eval to make this safe, $@ will contain any error
            $c->posts_for(uri =>"$currentURI");
        }
        my $error = $@;
        if (defined($error)) {
            warn($error);        # If eval failed, warn and skip to next line
            next;
        }
        if (! @tags) {
            next;                # Assuming no tags means go to next line in input
        }
        ... do something ...
    }
    

    All eval really does here is guarantee that Perl errors which can be handled leave the eval block in the normal way, although if that happens, @tags will be empty, and $@ will contain the error. The remaining logic warns (and skips the input line) if $@ was set. You likely want to skip the line anyway if there are no tags.

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

Sidebar

Related Questions

I am trying to extract some data from a website using a LINQ statement,
I'm currently trying to extract data from a table, and am using this: $online
I'm trying to extract data from a data file that's tab-delimited (in some parts),
I am trying to extract data from XML. I generated C# classes using XSD
I am trying to extract data from a xml file, get rid of the
I am trying to extract data from a string using Regex in VB.net. This
I'm trying to extract data from an xml file. The problem is I know
I am trying to extract data from this String: Hello there. Blah blahblah blah
I'm trying to write a query that extracts and transforms data from a table
I am trying to automate data extraction from a website and I really don't

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.