In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Hamish Whittal) writes:
>Hi All,
>
>I have a module OraMod.pm that exports some subroutines....
>
>I also have Common.pm which sets up a whole host of environment
>variables for use throughout all the modules that I have created. What I
>now want to do is, instead of placing the
>
>use OraMod qw(sub1, sub2, sub3) at the top of all the modules that
>require it, I want to place it in the Common.pm module too.
>
>So I tried:
>use base 'Exporter';
>
>use OraMod qw(sub1, sub2, sub3);
>
>our @EXPORT = qw/$CONFIGDIR $RUNFILES $DefaultPollInterval
>$DefaultPollYN $DefaultCommunity/;
>$CONFIGDIR = '/export/home/whittalh/vodanam_update';
>$RUNFILES = '/tmp/run';
>$DefaultPollInterval = 24;
>$DefaultPollYN = 'Y';
>$DefaultCommunity = 'public';
>
>1;
>
>And at the top of OraMod.pm....
>
>use Exporter;
>@ISA = ('Exporter');
>@EXPORT_OK = qw(sub1 sub2 sub3);
>
> But alas, I still need to explicitly state the 
>
>OraMod::sub1(params......) in the modules that use the sub1.
>
>Any clew to what I am doing wrong.

The Exporter only exports to the caller by default.  So sub1() can
be called without qualification in OraMod.pm but not in OraMod's
caller unless you export it from there as well.

This should make it clear:

$ cat Foo.pm
package Foo;
use base Exporter;
use Bar;
our @EXPORT = qw(bar);
1;

$ cat Bar.pm
package Bar;
use base Exporter;
our @EXPORT = qw(bar);
sub bar { print "Bar\n" }
1;

$ cat foo
#!/usr/bin/perl
use strict;
use warnings;
use Foo;
bar();

$ ./foo
Bar

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to