likbez has asked for the wisdom of the Perl Monks concerning the following question:
Looks like I can't use our declaration for this purpose (see below) Does any other mechanism exist?
Also question about 'export" behavior". If I export variable debug from module A does it became "normal variable" in main:: so that I can use it in module B? what will happen if I export it from module b as well ? It should bind it to the same variable, right?
Can anybody enlighten me about this behavior? BTW does Perl have a system variable "debug" that is global and does not need qualification with the package name?
For example, if I created module example.pm it compiles OK, but produces a run time error because Perl assumes that our debug is $example::debug not $main::debug
May be our behavior can be generalized to handle this case as well? Why we can't alias variables in other namespaces? Is not this an artificial restriction?
It complains that it is undefined:package example; use v5.10; use warnings; use strict 'subs'; use feature 'state'; require Exporter; our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @ISA = qw(Exporter); $::debug=1; { our $debug; say "debug=$debug"; } $VERSION = '1.10'; 1; and the test script: <code> #!/usr/bin/perl #:: test of ours use v5.10; use warnings; use strict 'subs'; use feature 'state'; use lib '.'; use example; say "debug=$debug";
[255] # perl test_our_behaviour.pl <code> [0] # perl test_our_behaviour.pl Use of uninitialized value $example::debug in concatenation (.) or str +ing at example.pm line 14. IN EXAMPLE: debug= debug=1