A
Amit Brahme
Hi,
I want to know if perl can do following thing.
------------------------------------------------------------------------
I've a package and some variables defined in it, like below, in file
lets say "junk1.pm".
******************
package junk1;
$foo = "xyz";
$abc = "123";
******************
In my program I write a code like
******************
require "junk1.pm";
$myrf = "junk1";
print $junk1::foo;
******************
What I want is: instead of using
print $junk1::foo;
I want to use $myrf (which is defined as "junk1") to access variable
"foo" in package junk1.
I tried
print ${$myrf}::foo;
but perl gives error for this that it found barework foo. Is there any
way I can do something like this?
I want to know if perl can do following thing.
------------------------------------------------------------------------
I've a package and some variables defined in it, like below, in file
lets say "junk1.pm".
******************
package junk1;
$foo = "xyz";
$abc = "123";
******************
In my program I write a code like
******************
require "junk1.pm";
$myrf = "junk1";
print $junk1::foo;
******************
What I want is: instead of using
print $junk1::foo;
I want to use $myrf (which is defined as "junk1") to access variable
"foo" in package junk1.
I tried
print ${$myrf}::foo;
but perl gives error for this that it found barework foo. Is there any
way I can do something like this?