Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: I just want to include another file

by hmerrill (Friar)
on Sep 15, 2004 at 11:55 UTC ( [id://391135] : note . print w/replies, xml ) Need Help??


in reply to Re^2: I just want to include another file
in thread I just want to include another file

I don't have code at my fingertips to show you, but you don't have to declare variables in both files. If the export is done properly in the module, you can simply refer to the variables in the code that does the "use". I hope I'm not oversimplying here - it's been a while since I've done this, and I'm not actively using Perl now.

I also think when I did create modules that I used a simplified approach of not doing "export"s at all. The "use" still worked the same, but to refer to variables in the module I had to use the module name, something like this:

use lib '/path/to/my/module/directory'; use MyMod; print "MyMod var1 value is $MyMod::var1\n";
Again, not sure if this is exactly right, but it should be close. I liked this approach because looking at the code you can always tell *where* a variable comes from - you don't need to go hunting around for it if you see that it hasn't been declared in the current module. You *are* using warnings(-w), strict, and declaring all your variables with "my", right??

HTH.