My program uses "accessors::rw qw ( <variable_name> );" to define
accessor methods for my modules. When I pack my program with pp and -x
option (which I use to pull in modules that load other modules at
runtime - thanks to Roderich) it fails saying that it "Can't call method
"my_var" without a package or object reference" at a line where I try to
use the accessor methods.
Here is a simplified example:
### package MyModuleA
package MyProject::MyModuleA;
use accessors::rw qw ( my_var );
sub new {
my $class = shift;
my %parameter = @_;
bless {
my_var => $parameter{value};
}, $class;
}
### package MyModuleB
package MyProject::MyModuleB;
use accessors::rw qw ( my_other_var );
sub new {
my $class = shift;
my %parameter = @_;
bless {
my_other_var => $parameter{value};
}, $class;
}
### I use both modules in my_program.pl
my $var1 = MyProject::MyModuleA->new(value => "a");
### pp fails, where I try to call the accessor method $var1->my_var
my $var2 = MyProject::MyModuleB->new(value => $var1->my_var);
Does someone know why and how I can find a workaround?
Any hints are appreciated!
Thank you!
Regards,
Nele