Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Symbolic reference with strict "refs"

by broquaint (Abbot)
on Aug 17, 2012 at 20:05 UTC ( #988092=note: print w/replies, xml ) Need Help??


in reply to Symbolic reference with strict "refs"

In your specific example you have at least two options:

  1. Rummage through package stashes and globs e.g
    @Foo::ISA = qw(Hello World); use strict; use feature 'say'; my $class = 'Foo'; my $isa = *{ $main::{"$class\::"}{ISA} }{ARRAY}; say "@$isa"; # Hello World
  2. Use the core package Symbol and make use of qualify_to_ref e.g
    @Foo::ISA = qw(Hello World); use strict; use feature 'say'; use Symbol 'qualify_to_ref'; my $class = 'Foo'; my $isa = *{qualify_to_ref 'ISA', $class}{ARRAY}; say "@$isa"; # Hello World
The former won't work with nested packages whereas the latter will.
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988092]
help
Chatterbox?
[marto]: no real change there then? :P
marto ducks

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2016-12-05 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (75 votes). Check out past polls.