Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
laziness, impatience, and hubris
 
PerlMonks  

how to find the value of variable?

by Divakar (Sexton)
on Aug 10, 2012 at 10:28 UTC ( #986713=perlquestion: print w/ replies, xml ) Need Help??
Divakar has asked for the wisdom of the Perl Monks concerning the following question:

i dont know how to find the value of variable while debugging. for e.g.,

DB<13> x $fh 0 FileHandle=GLOB(0x59fe84) -> FileHandle({*Symbol::GENO}) => fileno(3) DB<14>

i want to know how i can see the variable $fh.

Comment on how to find the value of variable?
Download Code
Re: how to find the value of variable?
by aitap (Chaplain) on Aug 10, 2012 at 11:20 UTC
    To your mind, what value should filehandle variable have? If you want to know the file name of the filehandle, you'll have to use IO::File::WithPath, IO::File::WithFilename or something like this.
    Sorry if my advice was wrong.
      I think this is right. Typically once the file system has opened a file, it doesn't care nor keep track of the text string that was used to open the file in the first place.

      So, if the OP means "what was the text file "name/path" for this filehandle?, the user program would have to keep track of that name/path which is what these modules appear to do. There are weird sorts of situations that can arise, but it doesn't sound like further elaboration is needed.

      As a practical debugging matter, I would just add a print statement with that info for debugging or make a log entry of some sort. Or print the $name that was used in the open() in the debugger rather than trying to make sense of the filehandle structure.

Re: how to find the value of variable?
by rpnoble419 (Pilgrim) on Aug 10, 2012 at 13:23 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2014-04-19 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls