in reply to Allowing user to change module variables
By declaring $oui_location with my, you've made it lexically scoped and unavailable to your other packages. There are a variety of strategies to deal with this. This simplest is to change package OUILookup:
$OUILookup::oui_location = "oui.txt";
When other code references this variable, simply refer to it with a fully qualified package name. However, global variables are usually a bad idea. You could use Exporter:
package Scrap::Foo; use strict; use Exporter; use vars qw/ @ISA @EXPORT $foobar /; @ISA = qw/Exporter/; @EXPORT = qw( $foobar ); $foobar = 7; sub doit { print $foobar; } 1
Then, in package main, I have the following:
use Scrap::Foo; use strict; $foobar = "Hello"; Scrap::Foo::doit;
That will print "Hello" instead of 7.
My suggestion, though, would be to create a set_oui_lookup() sub in your module. That's the cleanest solution.
Cheers,
Ovid
Vote for paco!
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|