Addressing a PACKAGE, sincerely confused: 
Author Message
 Addressing a PACKAGE, sincerely confused:

Quote:
> While hacking on my latest perl project, I found the need to manipulate
> variables within a package.  The following works:

>    $goo = $foo'bar;

> This stores the contents of variable bar in package foo into goo.

> So far so good. But suppose the package name was stored in a variable
> say:

> $package="foo";

> how do address bar now?  For example

> $goo = $$package'bar;

> fails miserably

This may not be pretty, but it works.

$goo = eval "\$${package}'bar";

Eric

Eric Wenokor--------------------------------------

53 Wall Street
New York, N.Y 10005                 (212) 858-7510
--------------------------------fax (212) 858-7620



Tue, 18 Jun 1996 20:30:32 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Addressing a PACKAGE, sincerely confused:(

2. confused packages use

3. CODE reference to member function of package Confusing..

4. confused by full package name and warning

5. package/object confuses each others variables?

6. Can't call method "Mail::Address::address" without a package - in my class

7. Need resolver from IP numeric address to alphabetic address

8. How to find IP address by MAC address?

9. Finding an email address by ip address

10. IO addresses, Memory Addresses and RS232 ports in DOS

11. How to find IP address by MAC address?

12. How to find IP address by MAC address?

 

 
Powered by phpBB® Forum Software