V
vabby
Hi
I have a a problem with function reference. I have a main module,
mod_main2.pl in which I call the function of a another module
Batlib22.pm, in the traditional way, ie by exporting the symbols in the
Batlib22.pm and not using the object oriented way.
So my Batlib.pm looks something like this:
package Batlib22;
use Exporter();
@ISA = qw(Exporter);
push(@EXPORT, '&fun2');
sub fun2
{
my ($arg1) = $_[0];
print "\n Now in Batlib2::fun2 fn \n";
print $arg1;
}
1;
and my mod_main2.pl looks sthing like this.
use Batlib22;
print " before calling fun2 the traditional way";
my $reffn = \&fun2(100);
&$reffn();
exit(0);
There are two problems I am facing :
1) As soon as I make the declaration my $reffn = \&fun2(100);
fun2() gets executed . i dont want this to happen . i want to store its
reference ina variable and use that variable latyer on for execution
purposes.
2)the call &$reffn(); gives rise to run time error:Not a CODE reference
at ./mod_main2.pl
PLz advise me where am I agoing wrong. I would really appreciate ur
help, here as I have a deadline to meet.
Tx in advance.
Vaibhav
I have a a problem with function reference. I have a main module,
mod_main2.pl in which I call the function of a another module
Batlib22.pm, in the traditional way, ie by exporting the symbols in the
Batlib22.pm and not using the object oriented way.
So my Batlib.pm looks something like this:
package Batlib22;
use Exporter();
@ISA = qw(Exporter);
push(@EXPORT, '&fun2');
sub fun2
{
my ($arg1) = $_[0];
print "\n Now in Batlib2::fun2 fn \n";
print $arg1;
}
1;
and my mod_main2.pl looks sthing like this.
use Batlib22;
print " before calling fun2 the traditional way";
my $reffn = \&fun2(100);
&$reffn();
exit(0);
There are two problems I am facing :
1) As soon as I make the declaration my $reffn = \&fun2(100);
fun2() gets executed . i dont want this to happen . i want to store its
reference ina variable and use that variable latyer on for execution
purposes.
2)the call &$reffn(); gives rise to run time error:Not a CODE reference
at ./mod_main2.pl
PLz advise me where am I agoing wrong. I would really appreciate ur
help, here as I have a deadline to meet.
Tx in advance.
Vaibhav