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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.