Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to get variable name in trace message

by stevieb (Hermit)
on Jun 15, 2012 at 05:45 UTC ( #976357=note: print w/ replies, xml ) Need Help??


in reply to How to get variable name in trace message

Does caller() appeal to you in this case?

ps. I don't know much about C, so this is just a guess.

Update: caller() won't print out the var & contents inherently, but it does of course produce a stack trace.


Comment on Re: How to get variable name in trace message
Download Code
Re^2: How to get variable name in trace message
by ChrisBeall (Novice) on Jun 15, 2012 at 06:02 UTC
    Hi stevieb - caller() is very impressive, but, as you say, it seems to relate more to doing a stack trace about function calls etc. I'm after a simple function (or "macro" equivalent) to just plonk out trace values of the form "<line_no>: <var_name> = <var_value>", using a command like "DEBUG(<var_name>)". I guess I could use the debugger, but this would be simpler for little tasks. The trick is I can't see how to find the <var_name> itself.

      I regretted posting originally, because I spoke before I fully comprehended what you were after.

      I've written such tools before, but they aren't worthy of public consumption. Hopefully someone will be able to finger a CPAN module that will get you on your way.

      Cheers,

      Steve

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976357]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (20)
As of 2014-07-30 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (239 votes), past polls