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.
| [reply] |
|
| [reply] |
|
| [reply] |
|
Re: Strict and warnings: which comes first?
by jcb (Parson) 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;
| [reply] [d/l] [select] |
|
use 5.008;
use strict;
use warnings;
... before even the package statement.
| [reply] [d/l] [select] |
|
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. :-)
| [reply] [d/l] [select] |
|
|
|
|
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.
| [reply] |
|
Re: Strict and warnings: which comes first?
by cavac (Vicar) 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=");'
| [reply] [d/l] [select] |
|
| [reply] [d/l] [select] |
|
| [reply] [d/l] |
Re: Strict and warnings: which comes first? (Simultaneous!)
by Anonymous Monk on Nov 07, 2019 at 13:26 UTC
|
| [reply] |
|
| [reply] [d/l] |
|
| [reply] |