in reply to Re: Traversing variables in a namespace
in thread Traversing variables in a namespace

Using eval is overkill in this case. It is more efficient and probably more straightforward to disable strict 'refs' and use symbolic reference to extract a variable's value from the symbol table:
for $name (keys %::) { no strict 'refs'; $val = $$name; }
   MeowChow                                               
                print $/='"',(`$^X\144oc $^X\146aq1`)[-2]

Replies are listed 'Best First'.
Re: Re: Re: Traversing variables in a namespace
by repson (Chaplain) on Feb 06, 2001 at 12:07 UTC
    If you remember that %main:: is a hash of globs, then a simple derefence works, doesn't worry strict and allows you to get all types of vars. But you may only want scalars, and not a scalar version of almost everything.
    for (keys %main::) { $val = ${ *{ $main::{$_} }{SCALAR} }; }
Re: {3} Traversing variables in a namespace
by jeroenes (Priest) on Feb 06, 2001 at 10:37 UTC