How can I list all variables that are in a given scope?

后端 未结 4 1232
半阙折子戏
半阙折子戏 2020-12-08 10:05

I know I can list all of the package and lexcial variables in a given scope using Padwalker\'s peek_our and peek_my, but how can I get the names an

4条回答
  •  难免孤独
    2020-12-08 10:31

    You can do something like the following to check the symbol table of the main package:

    {
        no strict 'refs';
    
        for my $var (keys %{'main::'}) {
            print "$var\n";
        }
    }
    

提交回复
热议问题