coding style - What is best practice as far as using perl-isms (idiomatic expressions) in Perl? -


Some years ago I participated in writing the best practice / coding style for our large (and often the use of Pearl)

As anything done unanimously, there were parts that disagreed with everyone. Duh

The section that has caused the most disturbance was a strong recommendation for using many parliaments (loose code idioms are not defined as C ++ or Java) Such as "Avoid experimentation" ... until X; "Constructs".

The main argument for such rules was that non-Pearl developers would have a hard time with the Pearl code base, I think the perception here is that the Pearl Code Jockey, rare breed overall - and newer work for the company than non-parallel.

I was wondering if the SO had any good reason to support or reject this argument It is ... this time mostly academic That is because the Perl coding standard of the company is ego and I will not be modified again as far as I know.

PS just to be clear, the question I did in context - an all The response to Pearl's small development store is obviously, "Pearl is using its maximum capacity".

What kind of perlisms do you mean?

Good:

  • Idiomatic for loops: (1..5) {} Or For (@foo) {}
  • arrays of scalar context Evaluation: my $ count = @items;
  • Map , Grep and sort : my% foo = map {$ _ - & gt; Id = & gt;

    OK if limited:

    • Statement control modifier - if, if not, Article etc.
      • Restricted to error trapping and quick return die "Bad Juju \ n" Unless $ Foo Eek 'Good Juju';
      • As Shawnn pointed out, another good use is the conditional assignment of the default values: my $ Foo = shift; $ Foo = 'blarg' as long as $ foo; No. Is this a cleaner, using IMO, a my $ foo = defined $ _ [0]? Change: 'blarg';
      • To avoid the reason: If you need to add additional behavior to the check or any other, then you have a large refatting job. IMO, the problem of resuming a statement (even in a good editor) is more disruptive than typing many "unnecessary" blocks.
    • Prototype - Map . The prototypes are not 'prototype' in the sense of any other language compiler signals.
    • Logical operators - standardize when using and and or versus. & amp; Amp; and || . All your codes should be compatible. Best if you use the Pearl :: Reviewer policy to implement. Avoid

    :

    • The local variable dynamic scope is very strange, and local anywhere local Not as it is.
    • Package variables enable bad behavior if you feel you need a globally shared situation, reactor if you still need a globally shared status , Then use the singleton.
    • Symbol table Harry

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -