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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:14:09+00:00 2026-05-11T02:14:09+00:00

Yes, the problem is with a library I’m using, and no, I cannot modify

  • 0

Yes, the problem is with a library I’m using, and no, I cannot modify it. I need a workaround.

Basically, I’m dealing with a badly written Perl library, that exits with ‘die’ when a certain error condition is encountered reading a file. I call this routine from a program which is looping through thousands of files, a handful of which are bad. Bad files happen; I just want my routine to log an error and move on.

IF I COULD modify the library, I would simply change the

die 'error'; 

to a

print 'error';return; 

, but I cannot. Is there any way I can couch the routine so that the bad files won’t crash the entire process?

FOLLOWUP QUESTION: Using an ‘eval’ to couch the crash-prone call works nicely, but how do I set up handling for catch-able errors within that framework? To describe:

I have a subroutine that calls the library-which-crashes-sometimes many times. Rather than couch each call within this subroutine with an eval{}, I just allow it to die, and use an eval{} on the level that calls my subroutine:

my $status=eval{function($param);}; unless($status){print $@; next;}; # print error and go to next file if function() fails 

However, there are error conditions that I can and do catch in function(). What is the most proper/elegant way to design the error-catching in the subroutine and the calling routine so that I get the correct behavior for both caught and uncaught errors?

  • 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. 2026-05-11T02:14:10+00:00Added an answer on May 11, 2026 at 2:14 am

    You could wrap it in an eval. See:

    perldoc -f eval 

    For instance, you could write:

    # warn if routine calls die eval { routine_might_die }; warn $@ if $@; 

    This will turn the fatal error into a warning, which is more or less what you suggested. If die is called, $@ contains the string passed to it.

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

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes. You can use *args as a non-keyword argument. You… May 11, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer Windows does not provide any mechanism for an application-wide font.… May 11, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer Web services, especially SOAP expect things like an XML envelope… May 11, 2026 at 8:26 pm

Related Questions

Yes, the problem is with a library I'm using, and no, I cannot modify
I'm having a problem with my compiler telling me there is an 'undefined reference
I'm trying to use a .NET assembly from VB6 via interop without placing it
The code I'm working with has its own smart pointer implementation which does simple
The situation is as follows. public interface IFoo { } public abstract class FooBase

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.