Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom error handling is catching errors that normally are not displayed
    text
    copied!<p>I am having a problem I can't seem to figure out and I hope you guys can help me.<br/> The problem occurs when :<br/></p> <ul> <li>I use custom errorhandling</li> <li>I use File::Stat in a seperate module</li> </ul> <p>Example:</p> <p>Main file</p> <pre><code>use strict; use warnings; # signal handling $SIG{__DIE__} = sub { my $error = @_; chomp $error; print "die: $error\n"; }; require mod; mod-&gt;get_stat(); </code></pre> <p>Module</p> <pre><code>package mod; use strict; use warnings; use File::stat; sub get_stat { my $file_path = "test.txt"; my $file_size = stat($file_path)-&gt;size; print $file_size; } 1; </code></pre> <p>This will cause the following output:</p> <pre><code>die: 1 die: 1 die: 1 die: 1 die: 1 4 </code></pre> <p>Now, if I remove my custom error handling OR if I <strong>use</strong> mod instead of <strong>require</strong> the die's will not be displayed.</p> <p>Interesting to see is that it <strong>does</strong> actually produce a result (test.txt is 4 bytes), meaning <strong>stat</strong> is working as it should.</p> <p>So, why am I getting this error ? Is this really an error ? Does the default perl error handling ignore errors that are "1"?</p> <p><strong>EDIT</strong><br/> As Linus Kleen remarked, the reason I get "1" is because I am displaying the amount of elements in the array.</p> <p>If I print out the content of the error instead, I get the following error:</p> <pre><code>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 </code></pre> <p>But still, I am getting an error that, without custom error handling, I do not get.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload