I seem to be stuck trying to access a scalar that is defined in another package and narrowed down the example to a simple test case where I can reproduce the problem. What I want to be able to do this refers to the list that is defined in the Example package, however, using our mechanism, Dumper shows that the variable is always undefined in example.pl:
Example. pm looks like this:
use strict;
use warnings;
use diagnostics;
package Example;
use Data::Dumper;
my $exported_array = [ 'one', 'two', 'three' ];
print Dumper $exported_array;
1;
And the code that uses this package is as follows:
use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use lib '.';
use Example;
{ package Example;
use Data::Dumper;
our $exported_array;
print Dumper $exported_array;
}
exit 0;
When this code is run, the first Dumper starts, and everything looks fine, after that the second Dumper, example.pl starts, and the link is undefined:
$VAR1 = [
'one',
'two',
'three'
];
$VAR1 = undef;