Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: using split

by educated_foo (Vicar)
on Jun 04, 2007 at 21:42 UTC ( [id://619238]=note: print w/replies, xml ) Need Help??


in reply to Re: using split
in thread using split

I probably should just keep quiet, but... your sample response could have been reduced to:
my $line = "This|that"; my @cols = split(/|/, $line); print "@cols";
While the orthodoxy around here seems to be that everything must use strict and warnings, they're just line noise in code snippets.

Replies are listed 'Best First'.
Re^3: using split
by GrandFather (Saint) on Jun 04, 2007 at 23:56 UTC

    I sort of agree in the case of fairly trivial code like this. However the OP didn't use strict so the sample should, and when we say "always use strictures" then don't it weakens the argument a little.

    Note too that this is not a "code snippet", but a full working script that demonstrates the OP's issue. <toungfirmlyincheek>Surely any complete application should include strictures?</toungfirmlyincheek>


    DWIM is Perl's answer to Gödel
      I can understand adding a "use strict" when it would highlight the problem, but the presence/absence of strict was strictly irrelevant to the OP's problem. I personally use strict in modules (i.e. code used by other code) but not in scripts, and find the Perlmonks "use strict" dogmatism heavy-handed and annoying.

      And surely any "complete application" should have a test suite, too, but we shouldn't expect people to include those with their replies!

        Perl gives you a whole pile of rope to do with as you like and by default doesn't do much about telling you about knots, kinks and loops tangled around your neck. Strictures go a little way toward helping coil things down in a tidy fashion.

        Ok, without the heavily drawn metaphorical image:

        Strictures cost almost nothing to add. In fact most editors will allow you to generate a template file that is used to add default text to a new document. Even experienced programmers generate typos from time to time and as with any form of bug, the sooner the error is detected the cheaper it is to fix. Indeed some editors perform dynamic syntax checking so typos are picked up immediately as the code is being entered.

        Sure, a test suite is a nice thing to have, but at the cost of at least doubling the initial cost of producing the code. Many people think them worth writing despite that. Strictures cost effectively nothing, require very little interpretation (especially for common errors), yet pick up the most common scripting language programming errors essentially immediately. Why wouldn't you use them - always.

        Dogmatic and heavy-handed? Quite possibly. Annoying? To a super-coder who never makes a typo maybe, but it really shouldn't worry most mere mortals. With good reason and in the interests of saving people time and making their lives happier? Absolutely! (Oh, and it should be "PerlMonks'" btw ;).)


        DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found