RE: pp wiht option -x fails when trying to execute accessor methods

2010-01-10 Thread Nele Kosog
Roderich,

thank you for your reply. I have to admit I probably did simplify my example 
too much when posting to the list ;-). I solved the problem my original 
question was addressing: Somewhere in the process of creating the executable I 
copied the modules to site/lib/my_project/ forgetting all about it and then 
wondering why there would be a difference between the local perl program and 
the creation of the pp executable (which uses site/lib/my_project since it's 
in @INC). Haha. Good laugh! Sorry for bugging you and everybody else.

Nele



pp wiht option -x fails when trying to execute accessor methods

2010-01-08 Thread Nele Kosog
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


Re: pp wiht option -x fails when trying to execute accessor methods

2010-01-08 Thread Roderich Schupp
On Fri, Jan 8, 2010 at 2:57 PM, Nele Kosog k...@sevencs.com wrote:
 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:

I'd say you simplified it a bit too much, because it works for me here
(after correcting an obvious typo)

   my_var = $parameter{value}; # semicolon should be a comma

BTW, the error message you got simply means: $var1 wasn't a blessed
reference, but rather a simpe scalar, e.g.

1-fubar

would elicit the same message.

Cheers, Roderich