Ralf Schaa wrote:

the module 'testMod.pm''
#==================================
package testMod;
use strict;
use Exporter;
our @ISA       = ("Exporter");
our @EXPORT    = qw($test &testThis);
our @EXPORT_OK = qw($test &testThis);

sub testThis{ our $test = "test";}
1;

the caller-program 'test.pl'
#==================================
use lib "E:/ddswork/process_data/_makeLevel2";
use testMod qw(&testThis $test);
use strict;

print "1: $testThis::test\n";
print "2: $test\n";

==> nothing is printed...

If you had turned the warnings on, it would gave printed the warning about the "Use of uninitialized value in string" so first of all move "use strict;" to the top and add "use warnings;" in your script and in the module.


You don't run the subroutine in your script, so it never sets the $test variable. Also, you try to print $testThis::test but your module's package is testMod, not testThis, so it should be $testMod::test instead. Try this:

#!/usr/bin/perl
use strict;
use warnings;
use lib "E:/ddswork/process_data/_makeLevel2";
use testMod qw(&testThis $test);

testThis();

print "1: $testMod::test\n";
print "2: $test\n";

__END__

You might want to rename your module to TestMod.
See perldoc perlstyle:

  Perl informally reserves lowercase module names for
  "pragma" modules like "integer" and "strict".  Other
  modules should begin with a capital letter and use
  mixed case, but probably without underscores due to
  limitations in primitive file systems' representations
  of module names as files that must fit into a few
  sparse bytes.

See also:

perldoc perlmod
perldoc perlmodlib
perldoc perlnewmod

http://www.perldoc.com/perl5.8.0/pod/perlmod.html
http://www.perldoc.com/perl5.8.0/pod/perlmodlib.html
http://www.perldoc.com/perl5.8.0/pod/perlnewmod.html
--
ZSDC



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to