Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Stray Variables

by jeyroz (Monk)
on Nov 05, 2004 at 19:01 UTC ( #405588=perlquestion: print w/replies, xml ) Need Help??

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

OK, newbie question. I have been modifying and re-modifying perl scripts and am finding old stray variables left behind here and there. The variables are being declared but not initialized in most cases. Is there a way the perl engine can detect an un-used variable? If I am using -w, will such warnings show up in an error log? Thanks for the help. - j

Replies are listed 'Best First'.
•Re: Stray Variables
by merlyn (Sage) on Nov 05, 2004 at 19:38 UTC
Re: Stray Variables
by Zaxo (Archbishop) on Nov 05, 2004 at 19:13 UTC

    There is a "used once" warning which does what you want. Just make sure you have warnings enabled and run. They will be logged if STDERR is, for instance in CGI.

    After Compline,

Re: Stray Variables
by csuhockey3 (Curate) on Nov 05, 2004 at 19:18 UTC
    always use strict and -w. Is there a reason you are not? Perhaps I am misunderstanding what you might need (say you are using -w), have a look at Tie::Scalar::Timeout (also hash and array), more of an OO approach.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2023-12-05 05:19 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (25 votes). Check out past polls.