in reply to poll ideas quest 2019

Strict and warnings: what comes first?

Please explain why below.

Update: Credits use strict; before/after use warnings; and Re^2: use strict; before/after use warnings;.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: poll ideas quest 2019
by Tux (Abbot) on Nov 06, 2019 at 15:40 UTC
    • use 5.18.3; use warnings;

    How many know that 5.12.0 was the first release that implies strict with use version? (well, actually 5.11.0, but I hope nobody is using 5.11.x in production code)

    (I don't care what version notation is used)


    Enjoy, Have FUN! H.Merijn
Re^2: poll ideas quest 2019
by Eily (Monsignor) on Nov 06, 2019 at 15:40 UTC

    As mentioned here, there might be some other options including -w and -W for warnings, and the implicit strict with use VERSION, but that would make a lot of possible answers if you were to enumerate all possible combinations...

    And to answer the question, I put the more significant first, so version first (optional), because it is actually strict + features + minimal version, then strict (even after a version) because it is more restrictive (but less rewarningsive) than warnings, and at last warnings.

    Edit: Oh, and if there's a package name, I always waste a few minutes deciding where I should put it, and then always add it after strict and warnings.

Re^2: poll ideas quest 2019
by LanX (Cardinal) on Nov 06, 2019 at 15:40 UTC
    > what comes first?

    use brain

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

    PS: at least that's what I keep telling my colleagues ;-)

      Although it could be argued that

      use strict; use warnings;
      is actually an attempt to
      use less brain;
      as it's a call for perl to do some of the thinking for you :)

        > is actually an attempt to

        > use less brain;

        well using brain leads to cleverly freeing brain by outsourcing, don't you think?

        Anecdote

        I recently tried to ride a full train, but adding two new routines:

        • having one eye on my bike
        • another eye on my mobile finishing a language lecture
        • (a third eye on the pretty lady having her bike stored behind mine)

        The effect was that I was so overly multi-tasked when leaving that I left my backpack (including a perl book and my passport) on the upper shelf.

        If I had been clever, (and I actually thought about it) I should have kept the backpack on my lap, because that's a no-brainer.

        Lesson: If you change your routine, only do it one step at a time, otherwise fall back to no-brainers.

        ... and what is programming else than changing (sub-)routines??? ;-)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Thankfully the only penalty is that I have to waste now 3 hours to recover my backpack from this train's home base in Monnem.

Re^2: poll ideas quest 2019
by Anonymous Monk on Nov 06, 2019 at 17:40 UTC
    Some people try to keep their use ...; declarations alphabetically sorted, saying that might help merges when multiple people add different uses... If one was to follow that route, use strict; would come before use warnings;.

      I quite often sort them on length. Just a silly example:

      use 5.18.2; use warnings; use Carp; use DB_File; use DateTime; use Data::Peek; use File::Glob; use XML::Simple; use Time::HiRes; use Text::CSV_XS; use Sys::Hostname; use Tie::Hash::DBD; use File::Basename; use Module::Refresh; use Module::CoreList; use HTML::TreeBuilder; use DateTime::TimeZone; use Proc::ProcessTable; use Encode qw(encode decode);

      Enjoy, Have FUN! H.Merijn

      Ah yes, having so many use statements in a single file that you have to sort them to make them manageable, that happens all the time :'(. And having to add a bunch of modules in one go is common enough that two people do it in parallel on a daily basis. So annoying :/

        You do not need to add several to run into problems if you do not have an agreed upon place to add them.

        Are you going to add the single new one at the end? Alphabetically? Under a related module?

        Jenda
        1984 was supposed to be a warning,
        not a manual!