CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [KevinR] hash of hashes disappears: Edit Log



efoss
Novice

Jul 21, 2009, 10:27 PM


Views: 5034
Re: [KevinR] hash of hashes disappears


In Reply To
Can you be more specifc about where the problem is in that code you posted?

Declaring all your variables as global variables is not the way to write good code. Variables should be scoped to just the section of code they are used in.


Sorry for the very late response to this.

I almost always declare all of my variables globally because I feel like it minimizes the chance of my making mistakes. Perhaps I should rethink that philosophy, but I'm quite sure that it's not what is causing me problems.

I just ran in to this same problem again in an entirely unrelated script. Here I'm making a hash of hashes (not sure if that's relevant to this or if it could happen with just any variable) and it disappears. This time I've put a debugger "block" in outside of the block of code where I filled the variable and everything is still fine - the variable is there and filled as I had intended. Then I start stepping through the code in the debugger and at one completely innocuous step (opening a file or writing something to a file), my stored variable just disappears. It's not that it empties out and is filled with nothing - it's just gone. It's not even there in the debugger. And when I run the script from a terminal, I get the same result. It seems to me that this has to be a problem with the interpreter. I don't see what else it could possibly be, although I'm certainly aware that mistakes generally lie with the person writing the code rather than some widely distributed tool. (I'm using the perl that came on my Mac OS X Leopard.)

I have attached all of my code, though I don't expect that this will help anyone. Really the question is: How can a variable disappear when you click one step through on your debugger and that step has absolutely nothing to do with the variable that disappears?


(This post was edited by efoss on Jul 21, 2009, 10:36 PM)
Attachments: clique_maps_072109_1.pl (8.63 KB)


Edit Log:
Post edited by efoss (Novice) on Jul 21, 2009, 10:36 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives