package AAA;
use 5.20.1;
use lib ('.');
use BBB;
use parent('Exporter');
our @EXPORT=('$bbb','$msg');
our $bbb=BBB->new();
return 1;
package BBB;
use 5.20.1;
use lib '.';
use AAA;
sub new{
my $class=shift;
my $self=bless {},$class;
return $self;
}
sub hello{
my $self=shift;
say 'hello';
}
sub hello2{
my $self=shift;
$bbb->hello();
}
return 1;
package main;
use 5.20.1;
use lib ('.');
use AAA;
$bbb->hello2();
perl test.pl
Global symbol "$bbb" requires explicit package name at BBB.pm line 16.
Compilation failed in require at AAA.pm line 4.
BEGIN failed--compilation aborted at AAA.pm line 4.
Compilation failed in require at test.pl line 4.
BEGIN failed--compilation aborted at test.pl line 4.
variable $bbb is exported only to package main, not package BBB. I want to make $bbb global to any packages |