in reply to Re^3: Perl logical operators
in thread Perl logical operators

hippo:

Yeah, but I'd really like to see it become the default.

Were I to do it, I'd make strict/warnings default, and provide an environment variable to control it. Something like:

PERL5STRICT:

My second preference (should people dislike the idea of changing the default behavior even with a global override) would be to use this behavior if you invoke perl as perl5, and when you invoke it as perl it would do as it does currently (i.e., act as if PERL5STRICT is 0). That way, I could just link perl to perl5 and change my typical shebang line to:

#!env perl5

Hmmmm .... I wonder if they would accept a patch? I doubt it would be very difficult, and I currently have some free time on my hands.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^5: Perl logical operators
by Your Mother (Archbishop) on Jul 18, 2018 at 18:51 UTC

    From my perspective I don't want it to be a plain default. I use Perl on the command line a great deal and having to type "my" and such "just because" would be a small burden but one that would add up quickly to be extremely irritating; irritating to the point of exploring other languages to see if they were less of a hassle. There may be some middle ground where -e turns off strict or any scope change turns it on or something(?).

    What haukex said about use {version} and backwards compatibility is germane I think.

      Your Mother:

      Having -e automatically disable strict/warn certainly sounds reasonable.

      I also either forgot (or didn't notice) that "use 5.12.0" would enable strict. On the bright side, that'll give me a couple things to look at to see how to implement such a feature. But since I've n ot put enough time into thinking about the various ramifications, I'll have to chew on it a bit longer. I'll also have to review the various perldeltas and see what other things I've missed. ;^)

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Re^5: Perl logical operators
by Anonymous Monk on Jul 19, 2018 at 09:21 UTC
    Perl5opt is already provided for that explicit purpose. PERL5STRICT is dumb.

      Nice! I really ought to review all the perl docs again and see what other interesting things I've missed.

      I just gave it a try, and it seems to work well. I went ahead and updated my .bashrc file:

      . . . export PERL5LIB="/mystuff/Perl/LIB" export PERL5OPT="-Mstrict -Mwarnings" alias p5="perl -Mstrict -Mwarnings" . . .

      and now have the behavior I want. Pretty nice.

      The PERL5OPT setting might interfere with some other scripts (I won't know until I run into one of them), so I created an alias to do essentially the same thing. (I wonder why I haven't thought of that earlier?) I'll remove the PERL5OPT setting if/when it causes me any grief. As Your Mother mentions earlier, it's often going to be a problem for one-liners. I rarely use one-liners, but I don't know how many are embedded into many of the tools I use.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Note that strict and warnings are lexical pragmas. It will only apply to the code or file you execute directly, not any included modules. This is a good thing; you don't want to have to fix bugs you introduced to code you didn't write. (This is also why -w and -W are the wrong approach.)