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

on windows I tried to use strict I get the error message: Can't declare undef operator in my at D:\users\cbccb1e0005\tools\Perl\lib/strict .pm line 8, near ") =" does anybody know what that means?

Replies are listed 'Best First'.
Re: strict.pm error
by Corion (Patriarch) on Dec 21, 2011 at 14:39 UTC

    I would assume that you are mixing versions of strict.pm and versions of Perl.exe that were not distributed together. Stop doing that.

    The line in question is

    my (undef, $f, $l) = caller;

    ... which works under 5.12 and (obviously) 5.14. You can go and look at strict.pm to see what version of the file you have, and then run perl -v to see what version of Perl you are running, and then at perlrun to investigate why your version of Perl is picking up files from a version of Perl that it should not see.

      Thanks a lot, I had an old perl version on PC and the newer version in bin directory. I cannot change path and settings on my notebook. The Version did in deed not match the strict.pm. Sorry I am an bloody greenhorn

        You can indeed change the path and the environment before invoking Perl. For example, I use a batch file like this to set up the environment for every version of Perl I use:

        @echo off set base=%~dp0 path %BASE%perl\bin;%BASE%c\bin;%BASE%perl\site\bin;%PATH%

        This file lives in the base directory of every Perl installation I have, like C:\strawberry-5.10 and C:\strawberry (which is currently 5.12). If I want to switch to a particular Perl, I invoke the batch file in the appropriate directory and thus switch the Perl for that shell window.

Re: strict.pm error
by NetWallah (Canon) on Dec 21, 2011 at 14:39 UTC
    You probably have a statement in your code like:
    my ($x, undef, $y) = something()...;
    This should work in most versions of perl after 5.6.

    What version of perl are you using (run "perl -v").

    A workaround would be to change the "undef" to a name like "$unused_1".

                "XML is like violence: if it doesn't solve your problem, use more."

      This was exactly the problem. I was running an older version of perl. Thanks a lot for your help
Re: strict.pm error
by Eliya (Vicar) on Dec 21, 2011 at 14:38 UTC

    My guess would be that your perl (the one that's actually loading strict.pm) is too old for the syntax

    my (undef, $f, $l) = caller; ^^^^^
Re: strict.pm error
by Anonymous Monk on Dec 21, 2011 at 14:37 UTC

    Can't declare %s in "%s"

    (F) Only scalar, array, and hash variables may be declared as "my", "our" or "state" variables. They must have ordinary identifiers as names.

    See perlintro, diagnostics