
FishMonger
Veteran
/ Moderator
Mar 20, 2014, 6:55 AM
Post #2 of 2
(3358 views)
|
Re: [alferic] passing hash from subroutine to subroutine
[In reply to]
|
Can't Post
|
|
First, you're missing 2 very important use statements which should be in every script you write.
use strict; use warnings; Or, if you're using one of the newer versions of perl, which you should be doing, you can do this instead which loads those pragmas as well as several other commonly needed modules. Next, don't use '&' when calling subs unless you know, understand and want its side affects. My answer to your question is to not use the our keyword, which creates a global var, unless that var really does need to be global. Vars almost never need to be global. Your incomplete code snippet doesn't provide enough info on what you're trying to accomplish to be able to show you how to fix it without doing a lot of guess work on my part. What does your module supposed to do? How does it relate to your sample code? It would be best to post a short but complete test script and module which demonstrates your problem. If you have, as I assume, vars declared in the module which you want to use in the script, then those vars normally should be exported.
|