M
Madhu Ramachandran
all:
I want to call subroutine, but the name of the subroutine itself is in a
variable. I was able to do this. However, i also want to pass arguments ..
not able to do this.
eg: if $sub has the subroutine name, and $arg has the arg to the subroutine.
How can i call this from my perl main program? i tried eval() and it worked
if i dont have any arguments.
#!/usr/local/bin/perl
$method="aSub";
$aa="\"bla\"";
$mm = "$method" . "($aa)";
print ("mm = $mm\n");
$ret = eval($mm);
print ("ret = $ret\n");
$ret=eval($method);
print ("ret = $ret\n");
sub aSub()
{
my ($arg1) = @_;
print ("inside aSub, arg1=$arg1\n");
return 1;
}
##### Output ######
mm = aSub("bla")
ret =
inside aSub, arg1=
ret = 1
##################
My perl version: This is perl, v5.6.0 built for sun4-solaris
any pointers?
Thanks in advance.
Madhu
I want to call subroutine, but the name of the subroutine itself is in a
variable. I was able to do this. However, i also want to pass arguments ..
not able to do this.
eg: if $sub has the subroutine name, and $arg has the arg to the subroutine.
How can i call this from my perl main program? i tried eval() and it worked
if i dont have any arguments.
#!/usr/local/bin/perl
$method="aSub";
$aa="\"bla\"";
$mm = "$method" . "($aa)";
print ("mm = $mm\n");
$ret = eval($mm);
print ("ret = $ret\n");
$ret=eval($method);
print ("ret = $ret\n");
sub aSub()
{
my ($arg1) = @_;
print ("inside aSub, arg1=$arg1\n");
return 1;
}
##### Output ######
mm = aSub("bla")
ret =
inside aSub, arg1=
ret = 1
##################
My perl version: This is perl, v5.6.0 built for sun4-solaris
any pointers?
Thanks in advance.
Madhu