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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:04:40+00:00 2026-05-26T18:04:40+00:00

I am having a problem I can’t seem to figure out and I hope

  • 0

I am having a problem I can’t seem to figure out and I hope you guys can help me.
The problem occurs when :

  • I use custom errorhandling
  • I use File::Stat in a seperate module

Example:

Main file

use strict;
use warnings;

# signal handling
$SIG{__DIE__} = sub {
    my $error = @_;
    chomp $error;
    print "die: $error\n";
};

require mod; 

mod->get_stat();

Module

package mod;

use strict;
use warnings;
use File::stat;

sub get_stat {
    my $file_path = "test.txt";
    my $file_size = stat($file_path)->size;
    print $file_size;
}

1;

This will cause the following output:

die: 1
die: 1
die: 1
die: 1
die: 1
4

Now, if I remove my custom error handling OR if I use mod instead of require the die’s will not be displayed.

Interesting to see is that it does actually produce a result (test.txt is 4 bytes), meaning stat is working as it should.

So, why am I getting this error ? Is this really an error ? Does the default perl error handling ignore errors that are “1”?

EDIT
As Linus Kleen remarked, the reason I get “1” is because I am displaying the amount of elements in the array.

If I print out the content of the error instead, I get the following error:

die: Your vendor has not defined Fcntl macro S_ISVTX, used at c:/Perl64/lib/File/stat.pm line 37.

die: Your vendor has not defined Fcntl macro S_IFSOCK, used at c:/Perl64/lib/File/stat.pm line 41.

die: Your vendor has not defined Fcntl macro S_IFBLK, used at c:/Perl64/lib/File/stat.pm line 41.

die: S_IFFIFO is not a valid Fcntl macro at c:/Perl64/lib/File/stat.pm line 41.

die: Your vendor has not defined Fcntl macro S_IFLNK, used at c:/Perl64/lib/File/stat.pm line 41.

4

But still, I am getting an error that, without custom error handling, I do not get.

  • 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-26T18:04:41+00:00Added an answer on May 26, 2026 at 6:04 pm

    As explained in perlvar, due to an implementation glitch $SIG{__DIE__} hooks get called even when code dies inside an eval. When File::stat is loaded, it checks to see what constants Fcntl supports on your platform. It catches the errors caused by unsupported constants, but not before your hook sees them.

    You can tell if you’re in an eval by checking the value of $^S. If it’s not 0, then you’re in an eval.

    $SIG{__DIE__} = sub {
        return unless defined $^S and $^S == 0; # Ignore errors in eval
        my ($error) = @_;
        chomp $error;
        print "die: $error\n";
    };
    

    You don’t see the errors when you use instead of require because use is a compile-time operation and require is a run-time operation (as is setting %SIG). When you use mod and it uses File::stat, that all happens before you set up your hook. When you require mod, that doesn’t happen until after you’ve installed your hook.

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

Sidebar

Related Questions

I'm having a problem that I can't seem to figure out, though I'm not
I am having a problem that I can't seem to figure out. What I
I'm new to url rewriting and having a problem i can't figure out. I
I'm having a problem and I can't figure out a clean solution. I have
I'm having a problem and can't seem to find the solution.. int linearSearch(nodeptr list,char
HI Guys, Here I am having problem that How can I post an image
I'm having a problem in ruby and I can't seem to find the solution
I'm having a problem with my site http://artygirl.co.uk/pixie/about/ I can't seem to get the
I seem to be having a strange problem which I can't fully understand. This
Having a problem I can't seem to put my finger on. I am trying

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.