From: "Dan Muey" <[EMAIL PROTECTED]>
> I was curious if there is a way to simply list all of perl's built in
> variables and their values.

You can list all variables in the main package:
(Beware! Ugly code follows!)

#!perl
use Data::Dumper;
$Data::Dumper::Indent = 0;
$Data::Dumper::Useqq = 1;
$Data::Dumper::Terse = 1;
$Data::Dumper::Sortkeys = 1;
foreach (keys %::) {
        next if /::$/; #I'm not interested in namespaces
        print "\$$_ = ", Dumper(${$::{$_}}), "\n" if defined ${$::{$_}};
        print "[EMAIL PROTECTED] = ", Dumper([EMAIL PROTECTED]::{$_}}), "\n" if 
defined @{$::{$_}};
        print "\%$_ = ", Dumper(\%{$::{$_}}), "\n" if defined %{$::{$_}};
}
__END__


%:: or %main:: is that hash containing all variables in the main 
namespace. The elements of the hash are references to TYPEGLOBs (or 
symbol table entries)  so you have to "dereference" those.

        perldoc perlref
and
        perldoc perldata
explain typeglobs.

Jenda


===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to