in reply to Identify Unused and Uninitialised variables.

Maybe using some editor-fu, like You do run under strict, right? :)


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Identify Unused and Uninitialised variables.
by JavaFan (Canon) on Jan 14, 2009 at 11:26 UTC
    Unfortunally, that may mean that the following code:
    sub foo { my $i; for $i (...) { ... if (...) { my $i; $i = something; ... } } }
    may end up as:
    sub foo { my $i; for $i (...) { ... if (...) { # my $i; $i = something; ... } } }
    However, the inner '$i' certainly wasn't an unused variable.

      You are right. You are absolutely right.

      Any code written like that could have unintended bugs but they will learn a valuable lesson in proper variable naming conventions at the same time.