700 Software
700 Software

Reputation: 87763

Coding in Perl: Finding unused variables

How can I locate unused variables and/or dead code in Perl? This can easily be done in Java with an IDE. Can it be done in Perl?

This is a single stand-alone script and I will spot any variables that might be used in one of the requires.

Upvotes: 17

Views: 4370

Answers (2)

August Karlstrom
August Karlstrom

Reputation: 11377

See warnings::unused.

This pragmatic module extends lexical warnings to complain about unused variables.

It produces warnings when a my variable or state variable is unused aside from its declaration.

Upvotes: 15

Wooble
Wooble

Reputation: 89887

Perl::Critic is a comprehensive package for source-code standards checking. It's capable of finding unused variables and unreachable code among many other things.

Upvotes: 17

Related Questions