B::Lint − Perl lint


perl −MO=Lint[,OPTIONS] foo.pl


The B::Lint module is equivalent to an extended version of the −w option of perl. It is named after the program lint which carries out a similar process for C programs.


Option words are separated by commas (not whitespace) and follow the usual conventions of compiler backend options. Following any options (indicated by a leading ) come lint check arguments. Each such argument (apart from the special all and none options) is a word representing one possible lint check (turning on that check) or is no-foo (turning off that check). Before processing the check arguments, a standard list of checks is turned on. Later options override earlier ones. Available options are:

Produces a warning whenever the magic "<>" readline is used. Internally it uses perl’s two-argument open which itself treats filenames with special characters specially. This could allow interestingly named files to have unexpected effects when reading.

  % touch 'rm *|'
  % perl −pe 1

The above creates a file named "rm *|". When perl opens it with "<>" it actually executes the shell program "rm *". This makes "<>" dangerous to use carelessly.


Produces a warning whenever an array is used in an implicit scalar context. For example, both of the lines

    $foo = length(@bar);
    $foo = @bar;

will elicit a warning. Using an explicit scalar() silences the warning. For example,

    $foo = scalar(@bar);

implicit-read and implicit-write

These options produce a warning whenever an operation implicitly reads or (respectively) writes to one of Perl’s special variables. For example, implicit-read will warn about these:


and implicit-write will warn about these:


Both implicit-read and implicit-write warn about this:

    for (@a) { ... }


This option warns whenever a bareword is implicitly quoted, but is also the name of a subroutine in the current package. Typical mistakes that it will trap are:

    use constant foo => 'bar';
    @a = ( foo => 1 );
    $b{foo} = 2;

Neither of these will do what a naive user would expect.


This option warns whenever $_ is used either explicitly anywhere or as the implicit argument of a print statement.


This option warns on each use of any variable, subroutine or method name that lives in a non-current package but begins with an underscore ("_"). Warnings aren’t issued for the special case of the single character name "_" by itself (e.g. $_ and @_).


This option warns whenever an undefined subroutine is invoked. This option will only catch explicitly invoked subroutines such as "foo()" and not indirect invocations such as "&$subref()" or "$obj−>meth()". Note that some programs or modules delay definition of subs until runtime by means of the AUTOLOAD mechanism.


This option warns whenever one of the regexp variables "$`", $& or "$'" is used. Any occurrence of any of these variables in your program can slow your whole program down. See perlre for details.


Turn all warnings on.


Turn all warnings off.


−u Package

Normally, Lint only checks the main code of the program together with all subs defined in package main. The −u option lets you include other package names whose subs are then checked by Lint.


Lint can be extended by with plugins. Lint uses Module::Pluggable to find available plugins. Plugins are expected but not required to inform Lint of which checks they are adding.

The "B::Lint−>register_plugin( MyPlugin => \@new_checks )" method adds the list of @new_checks to the list of valid checks. If your module wasn’t loaded by Module::Pluggable then your class name is added to the list of plugins.

You must create a "match( \%checks )" method in your plugin class or one of its parents. It will be called on every op as a regular method call with a hash ref of checks as its parameter.

The class methods "B::Lint−>file" and "B::Lint−>line" contain the current filename and line number.

  package Sample;
  use B::Lint;
  B::Lint−>register_plugin( Sample => [ 'good_taste' ] );
  sub match {
      my ( $op, $checks_href ) = shift @_;
      if ( $checks_href−>{good_taste} ) {


while(< FH >) stomps $_
strict oo
unchecked system calls
more tests, validate against older perls


This is only a very preliminary version.


Malcolm Beattie, mbeattie@sable.ox.ac.uk.


Sebastien Aperghis-Tramoni − bug fixes


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.