Hi Ralf,

TMHO, you should create the $test before printing it.

In fact, change 
        print "1: $testThis::test\n";
into 
        testMod::testThis(); 
        
and afterwards, the $test will be available.

OR: 

having $test global is not so profitable because you want be able to have
your personal $test variable.
You should better create it localy to testMod with the my (outside the
testThis) and call it using $testMod::test or better using a accesor.

#==================================
package testMod;
use strict;
use Exporter;
my $Test; # blabla..

our @ISA       = ("Exporter");
our @EXPORT    = qw(&getTest &testThis);
our @EXPORT_OK = qw(&getTest &testThis);

sub testThis{ $test = "test"};
sub getTest { return $Test };
1;

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

testMod::testThis();
print "1: ".testMod::getTest()." \n";
print "2: $test\n";


hope it help

Michel


-----Message d'origine-----
De: Ralf Schaa [mailto:[EMAIL PROTECTED]
Date: jeudi 4 mars 2004 13:51
À: [EMAIL PROTECTED]
Objet: packages and variables


Cheers all,

i am doing my first steps with writing packages/modules and of course 
there are problems:

the module holds a variable in a subroutine. this variable i like to 
pass to the callerprogram,
so it is in the @EXPORT_OK  and even in the @EXPORT. So far so good, i 
thought!
but nothing happens when i run the caller-program...

i  tried also defining with 'my ..' , or without 'use strict' ...

somebody has the clue?

thanx
-ralf


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...

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


--
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