我已经在eclipse中安装了epic用于调试perl。起初我在调试时看不到任何变量。我发现我需要安装PadWalker。这部分解决了这个问题,因为我可以看到所有变量,但我缺少内部变量(如@ARGV)。有什么建议吗? 使用centOS 6,eclipse版本:Kepler Service Release 1 Build id:20130919-0819 and epic
答案 0 :(得分:0)
可以从%main :: namespace中看到本地范围内的所有变量:
use Data::Dumper;
my @val;
my @names;
for my $name (keys %main::){
my $glob = $main::{$name};
if (defined ${$glob}) {
push @names, '$' . $name;
push @val, ${$glob};
}
if (defined @{$glob}) {
push @names, '@' . $name;
push @val, [@{$glob}];
}
if (defined %{$glob}) {
push @names, '%' . $name;
push @val, {%{$glob}};
}
}
my $d = Data::Dumper->new(\@val, \@names);
print STDERR $d->Dump
输出将如下:
$@ARGV = [
'aaa',
'bbb',
'ccc'
];
$@INC = [
'/usr/lib/perl5/5.10/i686-cygwin',
'/usr/lib/perl5/5.10',
'/usr/lib/perl5/site_perl/5.10/i686-cygwin',
'/usr/lib/perl5/site_perl/5.10',
'/usr/lib/perl5/vendor_perl/5.10/i686-cygwin',
'/usr/lib/perl5/vendor_perl/5.10',
'/usr/lib/perl5/vendor_perl/5.10',
'/usr/lib/perl5/site_perl/5.8',
'/usr/lib/perl5/vendor_perl/5.8',
'.'
];
$%INC = {
'warnings.pm' => '/usr/lib/perl5/5.10/warnings.pm',
'Carp.pm' => '/usr/lib/perl5/5.10/Carp.pm',
'XSLoader.pm' => '/usr/lib/perl5/5.10/i686-cygwin/XSLoader.pm',
'bytes.pm' => '/usr/lib/perl5/5.10/bytes.pm',
'warnings/register.pm' => '/usr/lib/perl5/5.10/warnings/register.pm',
'overload.pm' => '/usr/lib/perl5/5.10/overload.pm',
'strict.pm' => '/usr/lib/perl5/5.10/strict.pm',
'Exporter.pm' => '/usr/lib/perl5/5.10/Exporter.pm',
'Data/Dumper.pm' => '/usr/lib/perl5/5.10/i686-cygwin/Data/Dumper.pm'
};
$%ENV = {
'USERPROFILE' => 'C:\\Users\\Alex',
'HOMEDRIVE' => 'C:',
'PS1' => '\\[\\e]0;\\w\\a\\]\\n\\[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\$ ',
'COMMONPROGRAMFILES' => 'C:\\Program Files (x86)\\Common Files',
'APPDATA' => 'C:\\Users\\Alex\\AppData\\Roaming',
'PROGRAMFILES' => 'C:\\Program Files (x86)',
'OS' => 'Windows_NT',
'CommonProgramFiles(x86)' => 'C:\\Program Files (x86)\\Common Files',
'LOCALAPPDATA' => 'C:\\Users\\Alex\\AppData\\Local',
'PWD' => '/home/Alex',
'USER' => 'Alex',
'LANG' => 'C.UTF-8',
'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
'PRINTER' => 'HP Officejet 4620 series (Network)',
'SHLVL' => '1',
'NUMBER_OF_PROCESSORS' => '8',
'HOMEPATH' => '\\Users\\Alex',
'FP_NO_HOST_CHECK' => 'NO',
'QMAKESPEC' => 'cygwin-g++',
...