V
vabby
Hi
So this is my problem scenario. I have a main perl module, mod_main.pl,
and two other modules Batlib1.pm and Batlib2.pm .
In mod_main.pl I create an instance of Batlib2 :
$batlibobj2 = new_Batlib2 Batlib2();
And then an instance of Batlib1 where I pass the object of Batlib2.
$batlibobj1 = new_Batlib1 Batlib1($batlibobj2);
I then make a call to a test function fun1 in Batlib1.
$batlibobj1->fun1()
In my Batlib2.pm I have a simple test function fun2();
Inside Batlib1::fun1() , if I try to call Batlib2::fun2() by
$self->{batlibobj2}->fun2();
It works.
Also if I try to create a reference to the batlibobj2 ref and then call
fun2 the following way it still works:
my $refobj = \$self->{ batlibobj2};
$$refobj->fun2();
But when I try to create a reference to the function fun2 directly and
use it, perl starts cribbing.
my $reffn = \&$self->{batlibobj2}->fun2; ## the perl gives my runtime
error at this point . the error is "Not a CODE reference at
Batlib1.pm line 34".
&$reffn();
Is it that we cant have references to function which are defined in
other modules.
I am actually very new to perl programming . Plz tell where I am going
wrong.
Thanks in advance..
Vaibhav
So this is my problem scenario. I have a main perl module, mod_main.pl,
and two other modules Batlib1.pm and Batlib2.pm .
In mod_main.pl I create an instance of Batlib2 :
$batlibobj2 = new_Batlib2 Batlib2();
And then an instance of Batlib1 where I pass the object of Batlib2.
$batlibobj1 = new_Batlib1 Batlib1($batlibobj2);
I then make a call to a test function fun1 in Batlib1.
$batlibobj1->fun1()
In my Batlib2.pm I have a simple test function fun2();
Inside Batlib1::fun1() , if I try to call Batlib2::fun2() by
$self->{batlibobj2}->fun2();
It works.
Also if I try to create a reference to the batlibobj2 ref and then call
fun2 the following way it still works:
my $refobj = \$self->{ batlibobj2};
$$refobj->fun2();
But when I try to create a reference to the function fun2 directly and
use it, perl starts cribbing.
my $reffn = \&$self->{batlibobj2}->fun2; ## the perl gives my runtime
error at this point . the error is "Not a CODE reference at
Batlib1.pm line 34".
&$reffn();
Is it that we cant have references to function which are defined in
other modules.
I am actually very new to perl programming . Plz tell where I am going
wrong.
Thanks in advance..
Vaibhav