Click here to get back home

Get variable from its name string or vice versa?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Get variable from its name string or vice versa? Jerry Krinock 05-09-2008
Posted by jerrykrinock on May 9, 2008, 8:42 pm
Please log in for more thread options

> You can do this with PadWalker.

Thank you. I haven't tried it yet, but documentation of PadWalker
from CPAN declares a var_name() function that seems to be exactly what
I want.

Apparently this was a tricky feat. From the documentation: "I
wouldn't recommend using PadWalker directly in production code, but
it's your call. Some of the modules that use PadWalker internally are
certainly safe for and useful in production."

And from a review: "PadWalker is really, really useful if you need to
debug something really, really weird. I hope you never have to use
this module, but if you do, use it boldly."

:-|

Thanks for all the help. I'll probably give PadWalker a try next time
I am feeling bold, and have a little time to spare before production.

Jerry Krinock


Posted by Uri Guttman on May 9, 2008, 11:40 pm
Please log in for more thread options

>> You can do this with PadWalker.

j> Thank you. I haven't tried it yet, but documentation of PadWalker
j> from CPAN declares a var_name() function that seems to be exactly what
j> I want.

j> Apparently this was a tricky feat. From the documentation: "I
j> wouldn't recommend using PadWalker directly in production code, but
j> it's your call. Some of the modules that use PadWalker internally are
j> certainly safe for and useful in production."

j> And from a review: "PadWalker is really, really useful if you need to
j> debug something really, really weird. I hope you never have to use
j> this module, but if you do, use it boldly."

j> :-|

j> Thanks for all the help. I'll probably give PadWalker a try next time
j> I am feeling bold, and have a little time to spare before production.

and i doubt you have a legit reason to need this in production code. i
smell an XY problem here. when someone needs to use such a dark magic
solution, i say the problem is poorly specified or similar. tell us what
the real problem is, don't ask how to do something requiring magic. i
can find no good reason (other than debugging or wacko stuff) for
needing the name of a variable. and if you have anon references, you
can't get any name.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

Posted by Eric Pozharski on May 10, 2008, 4:00 am
Please log in for more thread options
jerrykrinock@gmail.com wrote:
*SKIP*
> Thanks for all the help. I'll probably give PadWalker a try next time
> I am feeling bold, and have a little time to spare before production.

(say that I'm wrong) Did you give up on debuger?


--
Torvalds' goal for Linux is very simple: World Domination

Similar ThreadsPosted
Calling C++ from Perl and vice versa January 22, 2006, 12:08 pm
Can I call Perl module from TCL or vice versa? October 10, 2006, 11:51 pm
PERL ---> Move email from Inbox folder to another or vice versa in OUTLOOK August 4, 2006, 10:39 pm
Using a string as a variable name. October 5, 2004, 10:34 am
setting a variable from a string August 12, 2005, 2:48 am
replace string with variable May 29, 2006, 6:06 am
How to "convert" a string into a variable name? August 2, 2006, 11:58 am
Using a variable in a matching string November 21, 2006, 1:18 pm
How do i get the charactors inside the ( ) from a string variable March 25, 2006, 2:46 pm
Modifying and printing a string variable September 12, 2006, 2:31 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap