llancet has asked for the wisdom of the Perl Monks concerning the following question:
Moreover, how to know whether an arbitrary package has a specific global?use strict; { package Foo; our $str = 'foo str'; } { package Bar; our $str = 'bar str'; } my $class = 'Foo'; # access Foo::str using soft ref my $value; { no strict 'refs'; my $soft = $class.'::str'; $value = $$soft; } # So, how to get $Foo::Str without soft ref?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to access globals in arbitrary classes, without using soft ref?
by moritz (Cardinal) on Feb 22, 2010 at 08:53 UTC | |
by llancet (Friar) on Feb 22, 2010 at 09:14 UTC | |
by ikegami (Patriarch) on Feb 22, 2010 at 16:10 UTC | |
|
Re: How to access globals in arbitrary classes, without using soft ref?
by shmem (Chancellor) on Feb 22, 2010 at 19:44 UTC | |
|
Re: How to access globals in arbitrary classes, without using soft ref?
by JavaFan (Canon) on Feb 22, 2010 at 11:14 UTC |