in reply to Re^2: accessing stashes
in thread accessing stashes
$My::{$symbol} returns a glob.
*NAME{SLOT} accesses a glob's slot.
*BLOCK{SLOT} accesses a glob's slot.
*$NAME{SLOT} accesses a glob's slot.
EXPR->*{SLOT} accesses a glob's slot.[1]
So,
my $glob = $My::{$symbol}; $glob && *{ $glob }{CODE} $glob && *$glob{CODE} $glob && $glob->*{CODE}
- Requires Perl 5.24+. Available in Perl 5.20+ by adding both use feature qw( postderef ); and no warnings qw( experimental::postderef );, or by adding use experimental qw( postderef );.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: accessing stashes
by ikegami (Patriarch) on Mar 01, 2019 at 19:52 UTC | |
Re^4: accessing stashes
by morgon (Priest) on Mar 01, 2019 at 19:25 UTC | |
by ikegami (Patriarch) on Mar 01, 2019 at 19:28 UTC | |
by morgon (Priest) on Mar 01, 2019 at 19:35 UTC | |
by ikegami (Patriarch) on Mar 01, 2019 at 19:55 UTC | |
by morgon (Priest) on Mar 01, 2019 at 20:18 UTC | |
|
In Section
Seekers of Perl Wisdom