in reply to use strict

- W (probably in - X) actually exists, contrary to something someone said in the Chatterbox earlier. It's a filetest operator. It tests to see if a file is writeable by the real UID/GID. Strict enforces good Perl habits, like not using symbolic references and things like that.

If you used that instead of -w, it's a typo. If not, what everyone else said is correct.

To see what kind of options you can feed Perl on the command line or the shebang line, see perlrun. (Note that the version on my box for 5.005_3 doesn't list anything for -W.)

Replies are listed 'Best First'.
RE: Re: use strict
by KM (Priest) on Jun 07, 2000 at 19:22 UTC
    To be more specific, -W tests to see if a file is writable by the real uid/gid. It would be used like:

    if (-W $file) { ... do happy stuff ... }else{ ... do unhappy stuff ... }

    Whereas -w is a switch used when running Perl to add a behaviour to the interpreter as it compiles and runs your code. You can see about the file test swicthes by typing:
    perldoc -f -X

    However, there is a -W switch for Perl 5.6 to turn on all warnings.

    Cheers,
    KM

      -W used on the perl command line has a different meaning. perl -W enables all warnings. perl -w enables many useful warnings. At least in perl 5.6 it does....
        What version of Perl are you using? -W didn't appear until 5.6, so it isn't relevent to everyone.

        # perl -W -e0 Unrecognized switch: -W (-h will show valid options).

        Cheers,
        KM