velocitymodel has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I am writing a code and keep coming up with errors for certain commands.

#!/usr/bin/perl $use strict; strict command not found

or

#!/usr/bin/perl use strict; No command 'use' found, did you mean ....

I get the same error message when using 'my' also. How do I correct this?

Replies are listed 'Best First'.
Re: Use strict.
by ikegami (Patriarch) on Jan 30, 2011 at 02:59 UTC

    You are not using perl to execute your scripts. Sounds like you are using a shell. Those messages are not coming from Perl. For a missing module, Perl would have used

    Can't locate strict.pm in @INC (@INC contains: ...) at ....

    Note that you have a space before "#!" in the second snippet, but they must be the first characters of the file to have their special meaning.

    Once you start running your snippets with Perl, you'll still have a problem with the first snippet.

    Bareword found where operator expected at ..., near "$use strict" (Missing operator before strict?) syntax error at ..., near "$use strict" Execution of -e aborted due to compilation errors.

    Get rid of the "$".

Re: Use strict.
by Anonymous Monk on Jan 30, 2011 at 00:44 UTC
Re: Use strict.
by ww (Archbishop) on Jan 30, 2011 at 02:20 UTC
    In your first example, Perl sees $use as a variable, and strict as a command (or 'verb') so what you've written won't work.

    But your second example appears reasonable... so you may need to check your installation -- are your modules where they should be; if you built your local Perl, did you do so properly?

    PS: it's good that you're using strict; go the whole way now, and add use warnings to see the helpful messages it will provide (or see the same errors with respect to warnings.pm.

    As to use of my, I have no clue what you mean: my $use strict; my strict; my what?.

Re: Use strict.
by JavaFan (Canon) on Jan 30, 2011 at 17:51 UTC
    The first error message is a typical shell error. If you execute the first snippet in a shell, it will disregard the first line (it's a comment), disregard the $use (it's undefined, hence an empty string), and cannot find the command 'strict'.

    I do not know which program has errors of the form "No command 'use' found, did you mean ...", but I do know Perl doesn't have errors looking like that.

      I do not know which program has errors of the form "No command 'use' found, did you mean ..."
      It's what ubuntu does when it thinks you're trying to run a command from a package you have not installed:

      $ hgh No command 'hgh' found, did you mean: Command 'huh' from package 'orville-write' (universe) Command 'hg' from package 'mercurial' (universe) hgh: command not found