As explained by Lotus1 &stat() isn't the same thing as stat(). &stat actually is the function in the *main::stat glob, which by default does not exist:
use v5.14;
use strict;
use warnings;
open my $fh, '>', "tmp_1222046.txt";
say 'stat($fh): ', join " ", stat($fh);
say '*::stat{CODE} is ', *::stat{CODE} // 'undef';
say '$sub = \&stat;';
my $sub = \&stat;
say '$sub: ', $sub;
say '*::stat{CODE} is ', *::stat{CODE} // 'undef';
say 'stat($fh): ', join " ", stat($fh);
say '$sub->($fh): ', join " ", $sub->($fh);
stat($fh): 0 0 33206 1 0 0 0 0 1536590875 1536590875 1536590555
*::stat{CODE} is undef
$sub = \&stat;
$sub: CODE(0x340be0)
*::stat{CODE} is CODE(0x340be0)
stat($fh): 0 0 33206 1 0 0 0 0 1536590875 1536590875 1536590555
Undefined subroutine &main::stat called line 18.
So accessing \&stat actually creates an entry in the symbols table, which is different from the function called with stat()
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.