<?xml version="1.0" encoding="windows-1252"?>
<node id="432752" title="betterworld's scratchpad" created="2005-02-19 11:46:48" updated="2005-08-11 03:46:29">
<type id="182711">
scratchpad</type>
<author id="432601">
betterworld</author>
<data>
<field name="doctext">
&lt;code&gt;
use strict;
use warnings;

use B;

package Foo;

sub thing {}

my $ref1 = \&amp;package1::sub1;
my $ref2 = \&amp;thing;

package Bar;

for ($ref1, $ref2) {
    print B::svref_2object($_)-&gt;STASH-&gt;NAME, "\n";
    print B::svref_2object($_)-&gt;GV-&gt;STASH-&gt;NAME, "\n";
}

# Output:
#   main
#   package1
#   Foo
#   Foo
&lt;/code&gt;
&lt;p&gt;Apparently &lt;code&gt;$cv-&gt;STASH-&gt;NAME&lt;/code&gt; is always "main" if the reference was constructed via an absolute name (like &lt;c&gt;$ref1&lt;/c&gt; was).&lt;/p&gt;</field>
</data>
</node>
