Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Devel::GC::Helper and unused variables

by 0xbeef (Hermit)
on Feb 26, 2007 at 20:02 UTC ( #602205=perlquestion: print w/replies, xml ) Need Help??

0xbeef has asked for the wisdom of the Perl Monks concerning the following question:

I need some guidance in my usage of Devel::GC::Helper. I thought it would show unused variables, but in this context it seems to be showing leaked CODE / ARRAYs. I have a perl script, with an external module wherein I have added:

use Devel::GC::Helper; my $leaks = Devel::GC::Helper::sweep; my $cnt = 0; for my $leak (@$leaks) { print "Leaked $leak\n"; print "detail: [@$leak]\n" if ($cnt); $cnt++; }

which gives

Leaked CODE(0x81f6e8c) Leaked ARRAY(0x81f6e98) Use of uninitialized value in join or string at eyemod.pm line 196. Use of uninitialized value in join or string at eyemod.pm line 196. detail: [ ] Leaked ARRAY(0x81f6ea4) Use of uninitialized value in join or string at eyemod.pm line 196. Use of uninitialized value in join or string at eyemod.pm line 196. Use of uninitialized value in join or string at eyemod.pm line 196. Use of uninitialized value in join or string at eyemod.pm line 196. Use of uninitialized value in join or string at eyemod.pm line 196. detail: [ ] Leaked ARRAY(0x81f6ed4) Use of uninitialized value in join or string at eyemod.pm line 196. detail: [ eyemod.pm eyemod import] Leaked ARRAY(0x8148be0) detail: [] Leaked ARRAY(0x8149708) detail: []

The detail is an effort on my side to show the content of the array in question, since I'm to dumb to translate ARRAY(0x8149708) into an array name. I'm too dumb to understand how to use perl -d for this. ;)

Does anyone perhaps know if I should be concerned about the Leaked warnings?

Secondly, does anyone know of a method to track down unused variables in large perl scripts, without the manual rigmarole? My searches lead me to perl_checker, but this seems to be intended for Mandriva.

Niel

Replies are listed 'Best First'.
Re: Devel::GC::Helper and unused variables
by Anonymous Monk on Feb 26, 2007 at 22:34 UTC
      Thanks I will try this out. Any idea what a leaked (ARRAY|CODE) may be in this context?

      Niel

Re: Devel::GC::Helper and unused variables
by bobf (Monsignor) on Feb 27, 2007 at 06:13 UTC

    Secondly, does anyone know of a method to track down unused variables in large perl scripts, without the manual rigmarole?

    I think the Name "%s::%s" used only once: possible typo warning will do what you want (see perldiag for caveats). You are using warnings, aren't you? ;-)

    Otherwise, maybe there is something in either Quickly detecting variable writes or in diotalevi's Devel::Spy that could suit your needs. If you figure something out, please post your solution.

      Yes, I have tried with both perl -w and use warnings, but this does not seem to detect unused declared variables that I add to test with.

      Thanks for the other info, I am trying some more now...

      Niel

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://602205]
Approved by kyle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2022-05-21 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?