Devel::FindGlobals

pudge on 2003-01-09T17:55:37

This module finds all your globals and prints out their sizes (thanks to Devel::Size). Here's an example of its use. It can also return the data as a hashref instead of printing it. Is it worth putting on the CPAN?

[pudge@bourque Data]$ perl -MDevel::FindGlobals -wle 'print print_globals_sizes(exclude_match => [qw(warnings overload VERSION$ EXPORT(_\w+)?$ Exporter Carp DynaLoader)])'

Name of SCALAR variable Size Total Size ================================================================================ $main::%08 96 96 $main::%0F 103 103 $main::%16 41 41 $main::%17 96 96 $main::%17ARNING_BITS 96 96 $main::%18 29 29 $main::! 96 96 $main::" 26 26 $main::$ 16 16 $main::+ 96 96 $main::- 96 96 $main::/ 98 98 $main::0 99 99 $main::1 96 96 $main::@ 264 264 $main::] 43 43

Name of ARRAY variable Size Total Size ================================================================================ @DB::args 56 56 @main::+ 108 108 @main::- 108 108 @main::ARGV 56 56 @main::INC 100 419 @main::_ 68 437

Name of HASH variable Size Total Size ================================================================================ %Config::Config 144 144 %main::@ 92 92 %main::ENV 1175 4824 %main::INC 540 1345 %main::SIG 1255 4424

Now Playing: It's Nice To Be With You - The Monkees (The Monkees Greatest Hits)


Useful

darobin on 2003-01-09T17:59:42

I believe it's useful and CPAN-worthy, notably for modperl apps. It would be nice to be able to filter out Perl's builtins as well to see what genuine globals have been introduced.

Re:Useful

pudge on 2003-01-09T18:16:33

It is easy to filter out any globals you want. You could add ^main:: and catch everything in the main package. Of course, someone could stick a new global in main, and you'd miss it ...

Umm... yeah?

rjray on 2003-01-09T21:17:58

CPAN that puppy forthwith. I agree that more filtering of Perl built-ins would be good (not just filter patterns, but actually avoiding $!, @+, @DB::args, etc.).

Re:Umm... yeah?

pudge on 2003-01-09T21:32:15

Patches welcome. ;-)

I'll commit it probably next week. My computing life is a shambles and I need to clean it up.