Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Strict and warnings: which comes first?

by choroba (Archbishop)
on Nov 07, 2019 at 11:19 UTC ( #11108437=poll: print w/replies, xml ) Need Help??

vote on Strict and warnings: which comes first?

Strict
[bar] 130/84%
Warnings
[bar] 24/16%
154 total votes
  • Comment on Strict and warnings: which comes first?
Replies are listed 'Best First'.
Re: Strict and warnings: which comes first?
by Lotus1 (Vicar) on Nov 07, 2019 at 21:33 UTC

    Other choices:

    • It depends on where I copy the program from.
    • What are strict and warnings?
    • Neither, I like surprises.
    • Neither, those things hurt job security.
      > Neither, those things hurt job security.

      hmm ... actually it never occurred to me that secretly deleting strict and warnings before delivering code might be a clever move. xD

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

        That's because you get better results by deleting your colleagues.

Re: Strict and warnings: which comes first?
by jcb (Deacon) on Nov 07, 2019 at 23:48 UTC

    I usually make those the first two non-comment non-blank lines in the file; and I put use strict; first as a matter of aesthetic taste — that both puts them in alphabetical order and gives a nice visual lead towards the right, where the later use statements are likely to end, since most module names are longer than warnings.

    Example:

    use strict; use warnings; use Storable;

    Some very useful modules break this pattern:

    use strict; use warnings; use DBI; use Tk;

      I usually put a use VERSION line before them. Most of my modules start off with something like:

      use 5.008; use strict; use warnings;

      ... before even the package statement.

        You are right: I think of package as part of the file header, so it goes in the very first line in a module, like the #! line in a script. I think that most of my code would probably run under 5.6, so my scripts generally lack use VERSION. I may need to see about changing that. :-)

        In my environment, I prefer to specify 'feature' rather than 'version' in part because it is much easier to specify correctly. When a module fails due to compatibility issues, 'feature' helps a maintenance programmer modify the module for an older perl. (If he choses to upgrade perl, he will probably upgrade to the newest version and not care about what is the oldest one he can get away with.) I do understand that 'version' is required by many development tools. That does not apply to me - at least not yet.
        Bill
Re: Strict and warnings: which comes first?
by cavac (Curate) on Nov 13, 2019 at 07:51 UTC

    In my code, i use (updateable-by-script) boilerplates:

    #---AUTOPRAGMASTART--- use 5.020; use strict; use warnings; use diagnostics; use mro 'c3'; use English qw(-no_match_vars); use Carp; our $VERSION = 2.3; use Fatal qw( close ); use Array::Contains; #---AUTOPRAGMAEND---

    ...and yes, i still need to switch to autodie

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'
      use 5.020; use strict;

      use 5.020 implies use strict (since v5.12) and use feature (not relevant here), even without loading strict.pm or feature.pm - see use.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        I know. But i decided to have "use strict" at the top of every perl file anyway. Just to make sure everyone reading it automatically knows it's in strict mode.

        perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'
Re: Strict and warnings: which comes first? (Simultaneous!)
by Anonymous Monk on Nov 07, 2019 at 13:26 UTC
    Simultaneous!
      Sex joke?

      sleep 2, print "Ho\n"  for 1..42

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

        Sex joke?

        Let the games begin!

        What does sex have in common with fractional numbers? It's improper for the larger one to be on top. :-)

        Just another Perl hooker - My clients appreciate that I keep my code clean but my comments dirty.

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2019-12-05 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (154 votes). Check out past polls.

    Notices?