A
A. Sicken
Hello,
I want to use the Exporter::export_fail-method to set some internal
debugging vars like:
use MyModul qw/enable_debug/; # to enable debugging messages
in following code example:
# --- CODE ---
use strict;
use 5.008; # and/or above version
package MyModul;
use Exporter;
our @ISA = qw/Exporter/; # to avoid namespace pollution
our @EXPORT_OK = qw/Some Symbols go here/;
our @EXPORT_FAIL = qw/enable_debug/;
our %EXPORT_TAGS = ( 'tag' => [@EXPORT_OK] };
our $VERSION = 1;
sub export_fail {
my $class = shift;
my $sym_name;
my @sym_fail;
while ($sym_name = shift) {
if ($sym_name eq 'enable_debug') {
# set var to use it later in module code
}else{
push @sym_fail, sym_name;
}#end_if
}#end_while
@sym_fail;
}#end_sub export_fail
# some module code goes hereafter
1;
__END__
# --- CODE ---
Now my questions: Is there a way to use the export_fail method without
declaring it within my module MyModul (or to destroy it after its first
invokation), because this means anyone can call this method as if it would
be a real method?
To clarify: I'm writing an oo-style framework/library and it seems
unnesseccary to me to provide this method as a real method for objects.
Maybe there is an easy way around this problem that takes inheritance into
account?
Thank you for your help and please excuse bad english.
A. Sicken
I want to use the Exporter::export_fail-method to set some internal
debugging vars like:
use MyModul qw/enable_debug/; # to enable debugging messages
in following code example:
# --- CODE ---
use strict;
use 5.008; # and/or above version
package MyModul;
use Exporter;
our @ISA = qw/Exporter/; # to avoid namespace pollution
our @EXPORT_OK = qw/Some Symbols go here/;
our @EXPORT_FAIL = qw/enable_debug/;
our %EXPORT_TAGS = ( 'tag' => [@EXPORT_OK] };
our $VERSION = 1;
sub export_fail {
my $class = shift;
my $sym_name;
my @sym_fail;
while ($sym_name = shift) {
if ($sym_name eq 'enable_debug') {
# set var to use it later in module code
}else{
push @sym_fail, sym_name;
}#end_if
}#end_while
@sym_fail;
}#end_sub export_fail
# some module code goes hereafter
1;
__END__
# --- CODE ---
Now my questions: Is there a way to use the export_fail method without
declaring it within my module MyModul (or to destroy it after its first
invokation), because this means anyone can call this method as if it would
be a real method?
To clarify: I'm writing an oo-style framework/library and it seems
unnesseccary to me to provide this method as a real method for objects.
Maybe there is an easy way around this problem that takes inheritance into
account?
Thank you for your help and please excuse bad english.
A. Sicken