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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:45:13+00:00 2026-05-16T17:45:13+00:00

I am writing a perl script, and in the part where I am checking

  • 0

I am writing a perl script, and in the part where I am checking the options that the user supplied on the command line, I want to exit with an error explaining what was wrong with the options. In this case, there is no need for a stack trace to go along with this error message. So what is the best way to die with an error message but no stack trace or debug information?

I’ve tried the following:

die "Invalid options";

which produces

Invalid options at myscript.pl line 49.

Then, I tried

use Carp;
...
croak "Invalid options";

which produces

Invalid options at myscript.pl line 47
    main::prepare_output_directory() called at myscript.pl line 546

So how can I just die with Invalid options and nothing else?

Bonus question: why does croak tell me that the error is at line 47, when the actual call to croak is on line 49?

  • 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-16T17:45:14+00:00Added an answer on May 16, 2026 at 5:45 pm

    Just put a newline at the end of the die string:

    die "Invalid options\n";
    

    That will prevent the location of the error from being appended to your message.

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

Sidebar

Related Questions

I'm writing this Perl script that gets two command line arguments: a directory and
I am writing a Perl script that can run both from command line and
I am writing a script that executes a command remotely via SSH using perl.
First question from a long time user. I'm writing a Perl script that will
I am writing a perl script. I want to filter out lines that do
I am writing a Perl script that is run by a user and makes
I'm writing a perl script that will access a MySQL database to determine whether
I am writing a Perl script (in Windows) that is using File::Find to index
I'm writing a Perl script that reads data from the infamous /dev/input/event* and I
I'm writing a shell script that before running needs to check that system Perl

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.