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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:44:37+00:00 2026-05-14T15:44:37+00:00

Is there a way in Perl to declare that a method can throw an

  • 0

Is there a way in Perl to declare that a method can throw an error (or die)?

EDIT: What interests me the most is a way to get the compiler or IDE to tell me I have an unchecked exception somewhere in my code.

I always loved how in Java, a method could handle an Exception and/or throw it. The method signature allows to put “throws MyException”, so a good IDE/compiler would know that if you use said method somewhere in your code, you’d have to check for the Exception or declare your function to “throws” the Exception further.

I’m unable to find something alike in Perl. A collegue of mine wrote a method which “dies” on incorrect input, but I forget to eval-if($@) it… offcourse the error was only discovered while a user was running the application.

(offcourse I doubt if there is any existing IDE that could find these kind of things for Perl, but atleast perl -cw should be able to, no?)

  • 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-14T15:44:38+00:00Added an answer on May 14, 2026 at 3:44 pm

    Two potential answers. Pick whichever you like better:

    1. In Perl, this is indicated by the module’s POD. There’s no way of marking it programmatically, so you need to rely on the documentation instead.

    2. Any method can die, or at least any nontrivial method. It’s going to call something else, which probably calls something else, etc., so the only way to guarantee that no exception will be thrown is to trace down through all the levels of (potential) calls to verify that there’s nothing there that might die. Much more pragmatic to just assume that exceptions are always a possibility and code accordingly.

    Edited to add: As a general rule, Perl5 and static code analysis don’t really get along all that well. My understanding is that this is one of the motivations behind the language redesign in Perl6, so you may have better luck there.

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

Sidebar

Related Questions

Is there any easy way to tell perl now ignore everything that is printed?
Is there a way to generate Excel spreadsheets with Perl on Linux so that
is there a way to get with printf colored output? #!/usr/bin/perl use warnings; use
Is there any way to get Perl to convert the stringified version e.g (ARRAY(0x8152c28))
Is there a way to output debug messages in Perl that are not piped?
I was wondering if there is a simple way in Perl to ensure that
Is there a way to get Perl to avoid treating negative values as command-line
is there a way to tell/force the perl compiler to cache values inside a
Is there a way to precompile a regex in Perl? I have one that
Is there a way to write tests for Perl calls that you expect 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.