Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Mr. BlindNewB question regarding spacing

by Anonymous Monk
on Oct 01, 2012 at 20:07 UTC ( #996733=note: print w/replies, xml ) Need Help??

in reply to Mr. BlindNewB question regarding spacing

While I cannot see the changes you made in your example (a problem with node formatting), the answer is yes, you can use whitespace. In fact, please add (a reasonable amount of) whitespace. Separate any logical blocks of code you have with an extra linebreak. I generally sprinkle one after (a group of) variable declarations, too. (But I hate "double-spaced" code.)

Also, use tabs to indent your code. Configure your editor to show them as n spaces, where n is a comfortable value (for you). I generally use a value of two spaces, but whenever I'm reading code I'm unfamiliar with, I'll increase it temporarily to four. It helps me understand the flow better.

You might also like the /x modifier if you're working with regular expressions. And if you don't have a syntax-colouring editor yet, get one immediately! It will help tremendously.

Here's what my code looks like, to give you a rough idea on what I consider OK spacing:

sub lint { my ($fn) = $_; $fn = decode_utf8($fn); if ($fn ne (my $new_fn = compose($fn))) { print STDERR "Decomposed unicode: $new_fn\n"; if (!DRY_RUN) { die if -e $new_fn; rename($fn, $new_fn) or warn "Failed rename for file $fn"; } } if (-f $fn) {

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996733]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-04-23 21:33 GMT
Find Nodes?
    Voting Booth?