<?xml version="1.0" encoding="windows-1252"?>
<node id="754182" title="How to get the name from a reference" created="2009-03-30 12:49:05" updated="2009-03-30 12:49:05">
<type id="115">
perlquestion</type>
<author id="750180">
michi</author>
<data>
<field name="doctext">
Hello,
i am looking for a way to get the "name" of a reference.
I hope this example explains what i mean:
&lt;code&gt;
sub my_sub { print "hello\n"; }
my $var = 5;

my $subname = some_nice_function(\&amp;my_sub); # should return 'main::my_sub'
my $varname = some_nice_function(\$var); # should return '$var' or 'var'
&lt;/code&gt;

I looking for a function (or any other way) that returns the string 'main::my_sub' if i pass a reference to my_sub. Is there any way to realize this?
</field>
</data>
</node>
