in reply to make a hash globally accessible

It would help if you post a bit of code so we can see what's going on. You are correct that a hash declared globally should retain its data throughout the program, but there are various ways one could subvert this. Perhaps you have redefined the hash within subs? Maybe you're not really assigning to the hash keys? Are you using conditionals that fail without warning? Is your hash being populated through files that aren't being opened, but you don't know that because you didn't check for a successful open? The possibilities are endless.

First, make sure that you are using the -w switch at the beginning of your program, that might catch a few things. Also, use strict;.

The only sure advice I can give you is to learn to use the perl debugger. Then, if your hash is named %somehash, when you get to an area of the program where the hash should be populated, you can type x %somehash to have a nicely formatted print of the hash contents, if any.

If you do post some code, be sure to wrap the code in <CODE></CODE> tags so it will be properly formatted.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.

  • Comment on (Ovid) Re: make a hash globally accessible