Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RE: On Testing and Formatting Code

by japhy (Canon)
on Oct 03, 2000 at 23:23 UTC ( [id://35173]=note: print w/replies, xml ) Need Help??


in reply to On Testing and Formatting Code

Very rarely do I not test code I post. I know I'm mortal, and code of mine can have errers [sic]. But as for my coding style, I tend to do the following:
  • BLOCKs are started with a brace on the line with the control structure (or function definition), and, except for one-liners, have all EXPRs in them on subsequent lines
    sub NAME { EXPR; EXPR; } sub NAME (PROTO) { EXPR; EXPR; } if (EXPR) { EXPR }
  • Semicolons are optional after one-liners (like above)
  • Closing braces appear on lines by themselves (except for in the case of one-liners (that means I do NOT "hug" my else's)
    if (EXPR) { EXPR } else { EXPR }
  • I use 2-space indents
  • Space between 'if' and '(', and between ')' and '{' (as shown above)
  • No space between function name and '('
    foo(1,2,3); bar({ a => $str, b => $trs, });
There's a myriad of other things I do, which can of course be divined from my code fragments I display on the site (or my programs you happen to come across).

$_="goto+F.print+chop;\n=yhpaj";F1:eval

Log In?
Username:
Password:

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

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

    No recent polls found