Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Align given substring(s) in lines

by GrandFather (Saint)
on Apr 28, 2021 at 21:58 UTC ( [id://11131828]=note: print w/replies, xml ) Need Help??


in reply to Align given substring(s) in lines

I don't understand your reason for not using strict.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Align given substring(s) in lines
by johnaj (Sexton) on Apr 28, 2021 at 22:24 UTC

    Without strict you can explore and try things more quickly and easily. If you use strict, then you have to write quite a bit of boilerplate, like variable declarations, which you are most likely going to have to remove later anyway, as you work your way through the problem and alter your approach.

    Basically, without strict you can get a working prototype much faster. Then you can add strict and all the usual boilerplate when you're done.

    Though I must admit I like that poem... :-)

      That goes completely against my experience (15+ years with Perl). The only "boilerplate" required by strict is to declare variables which typically consists of three extra characters - that is not onerous.

      Best practice is to only declare variables in the scope they are used and to initialize them when they are declared. In your sample code that amounts to 28 extra characters counting the "use strict;" statements. That is about a 2% overhead. 2% does not equate to "much faster" in my book.

      "running prototype" != "working prototype". A simple typo in a variable name that strict would have alerted you to can easily soak up tens of minutes of debugging time or introduce subtle calculation or logic errors that may go unnoticed. Just one case like that detected by strictures will more than outweigh the trivial overhead of the "boilerplate" over tens of projects.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

        I've already explained why it helps, and I'm not lying when I say it does help. Perl is the language of AND rather than OR, and there is more than one way to do it, so I personally don't value categorical imperatives about best practices too highly.

        (Also, perl -w warns you if you only use a variable once, so I don't think your example is valid. Of course, if you misspell it the same way twice, then you have problems.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found