You get two difference addresses because you take create references to two different subs, &main::stat and &CORE::stat.
First, you take the address of &main::stat. It's never defined.
$ perl -e'my $sub = \&stat; $sub->("a")'
Undefined subroutine &main::stat called at -e line 1.
Then, you take the address of &CORE::stat twice. The subs in CORE:: are automatically-generated wrappers for the operators of the same name, so you get a wrapper to the stat operator.
$ perl -e'my $sub = \&CORE::stat; $sub->("a")'
&CORE::stat cannot be called directly at -e line 1.
Well, it would be if stat had a calling convention that could be duplicated by subroutine prototypes. Instead, it's a wrapper for an error message.
-
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.
|