in reply to Inline Java in a Perl OO Module
use is executed as soon as it's compiled, but your placement of the statement suggests you think it will be executed when init is called, but that's not the case. It will only be executed once, and it will be executed whether init is called or not. The following code is equivalent to yours:
package ABC; use Inline Java << EOJ , .... .... EOJ ; sub new { .... } sub init { my $self = shift; $self->{obj} = ABC::javasclassfrominline->new() } sub somemethod { my $self = shift; $self->{obj}->callsomejavamethod(); } 1;
|
|---|