Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: use strict; before/after use warnings;

by Anonymous Monk
on Nov 07, 2019 at 04:42 UTC ( [id://11108421]=note: print w/replies, xml ) Need Help??


in reply to use strict; before/after use warnings;

I tried everything to make it shorter:
use strict, warnings;
use strict && warnings;
use for (strict, warnings); # no not really
The only thing I found was a replacement for strict:
use 5.12.0; # <- turns on strict
use strict; # <- but same length :-(

Replies are listed 'Best First'.
Re^2: use strict; before/after use warnings;
by haukex (Archbishop) on Nov 07, 2019 at 07:47 UTC
    use 5.12.0; # <- turns on strict use strict; # <- but same length :-(

    Same length, but use VERSION also turns on the corresponding feature bundle, which is IMHO pretty useful on newer versions of Perl. Also, the use 5.012; and use v5.12; forms are one character shorter :-)

      I hate programs that use 5.XX. Sometimes, I can't run them in an older Perl, but the only thing that's needed from the version feature bundle is say which started to exist in 5.10. I love explicit feature lists; that's also why I created Syntax::Construct.

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

        TIMTOWTDI. I loathe programs that use Modern::Perl, common::sense (yeah, right, not!), exact, or nonsense: They add dependencies that are not in core just to declare stuff that is in core already.

        I call these convenience modules (or pragmata). However useful they might be in your own working environment and force you into behaving well, adding them as a requirement to a CPAN module will increase the complexity of the requirements to probably no good use, as they are unlikely to be found on all your targeted systems and add a chance to break.

        Declaring use 5.18.3; might be more than just wanting to use strict and/or a specific feature: to me this sets a threshold for immediate failures where that script is used on a perl that is too old. It signals me that my/our lowest supported locally installed perl has to be updated/upgraded.

        If i need a module that uses Modern::Perl or Syntax::Contruct or whatever well thoughtthrough pragmatic module, I remove those declarations and replace them with what they declare to do, making it immediately clear to all maintaners following in my footsteps what the script/module depends on.

        Note that I have no influence on what "best practice" in whatever modules is changed without me knowing or setting a new restiction (like no indirect; which I happen to agree with) that will break all my code. No thanks.


        Enjoy, Have FUN! H.Merijn
        I hate programs that use 5.XX. Sometimes, I can't run them in an older Perl, but the only thing that's needed from the version feature bundle is say which started to exist in 5.10. I love explicit feature lists

        I agree that random unnecessary use VERSIONs are annoying, but I personally also don't really like typing out long lists of the features I want to use, and keeping that list up-to-date. So most of the time I write scripts in one of two different ways: backwards-compatible, for scripts down to 5.10 and for modules 5.6 or 5.8, or when I know for sure the script will be running on a modern Perl, I'll do use 5.026; or use 5.028;.

        My perl installations typically lag some versions behind, mostly due to lazyness. On my servers, I run Slackware. Currently, that means Slackware 14.2 and Perl 5.22. (Yes, it's the system perl. Slackware does not use Perl, but it comes with perl. So messing with the system perl is ok on Slackware.) On Windows, I have some Strawberry Perl running, an old 5.14 installation at home, a slightly newer version at work (I think 5.2x), still running dmake (so less than 5.26).

        Mentally, I am still mostly at v5.12: Perl 5 with say, s///r, and use VERSION implying strict. So I generally start my code (both scripts and modules) with:

        use v5.12; use warnings;

        Alexander

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found