Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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.

Replies are listed 'Best First'.
Re: how to find the value of variable?
by aitap (Deacon) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://986713]
Approved by lidden
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2017-06-27 21:02 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (613 votes). Check out past polls.