![]() |
|
Do you know where your variables are? | |
PerlMonks |
Re: Perl Riddleby Somni (Friar) |
on Dec 01, 2007 at 10:35 UTC ( #654302=note: print w/replies, xml ) | Need Help?? |
It's really hard to pin down what your problem might be because you're not actually showing any of the code that calls these functions. I'd guess that the problem is you just aren't initializing %ENGINES before you start calling subroutines that use it.
Your use of strict and our is broken, however. Because they are both in a BEGIN block the scope of both is confined to just that block, making them essentially useless. It's best to have use strict (and probably a use warnings) at the top of your code, outside of any block. The declaration for %ENGINES could be at the top, if you like, but I prefer to have the 'our' declaration near where I actually use the variable. If you intend to initialize %ENGINES at module startup then putting the declaration in a block can be a good idea.
This provides some self-documentation; it's clear that %ENGINES is global. You can also initialize %ENGINES outside a block, and not have to declare it in your subroutines.
In Section
Seekers of Perl Wisdom
|
|