Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coding in Perl: Finding unused variables

Tags:

perl

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.

like image 371
700 Software Avatar asked May 12 '11 18:05

700 Software


People also ask

What is $& in Perl?

$&, $MATCH: Used to find the string matched in the last successful pattern search. Though Matched in a hidden block or enclosed in the current set are not counted. This is a read-only variable and is scoped dynamically. #!/usr/bin/perl. # Declaring local string.

How do I declare an empty variable in Perl?

In perl, there's never any need to declare a variable before you use it. If you use an unitialized variable in a numeric context, it will take on the value 0; if you use it in a string context, it will take on the value of the empty string ("").


Video Answer


1 Answers

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.

like image 167
Wooble Avatar answered Sep 20 '22 21:09

Wooble