http://www.perlmonks.org?node_id=848787


in reply to 'use strict' without a semicolon can be interesting

It seems to me like it would be nice if this gave some sort of an error.

The syntax for use is use Module EXPR;, where EXPR is an expression that returns a list of symbols to import (or a list of strictures to enable in strict's case), and that's exactly what you provided. How can Perl possible know that what you meant something other than what you told it?

still behaves the same way in perl 5.8.12.

5.8.9 is the highest release of 5.8. You probably meant 5.12.0 or 5.12.1.

Replies are listed 'Best First'.
Re^2: 'use strict' without a semicolon can be interesting
by toma (Vicar) on Jul 13, 2010 at 18:20 UTC
    Perhaps there are a limited number of strictures that use strict knows about. Perl could compare the EXPR list against the known list of possible strictures, and throw an error or warning if the EXPR is not on the list.

    I don't know if this is feasible to implement without deep changes, but it does seem possible.

    You are right, I meant perl 5.12.1!

    It should work perfectly the first time! - toma

      It already does that.

      $ perl -e'use strict "foo"' Unknown 'strict' tag(s) 'foo' at -e line 1 BEGIN failed--compilation aborted at -e line 1.

      You passed an empty list which is perfectly valid (i.e. the same as use strict;).