Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Symbolic reference with strict "refs"

by broquaint (Abbot)
on Aug 17, 2012 at 20:05 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://988092]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2024-03-29 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found