michi has asked for the wisdom of the Perl Monks concerning the following question:
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?sub my_sub { print "hello\n"; } my $var = 5; my $subname = some_nice_function(\&my_sub); # should return 'main::my_ +sub' my $varname = some_nice_function(\$var); # should return '$var' or 'va +r'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to get the name from a reference
by repellent (Priest) on Mar 30, 2009 at 17:12 UTC | |
by chromatic (Archbishop) on Mar 30, 2009 at 17:26 UTC | |
|
Re: How to get the name from a reference
by Fletch (Bishop) on Mar 30, 2009 at 17:17 UTC | |
|
Re: How to get the name from a reference
by Marshall (Canon) on Mar 30, 2009 at 20:09 UTC | |
|
Re: How to get the name from a reference
by ikegami (Patriarch) on Mar 30, 2009 at 17:20 UTC | |
|
Re: How to get the name from a reference
by michi (Novice) on Mar 31, 2009 at 17:28 UTC | |
|
Re: How to get the name from a reference (data dump dumper varname var name)
by Anonymous Monk on Sep 10, 2013 at 09:03 UTC |