Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Mr. BlindNewB question regarding spacing

by Anonymous Monk
on Oct 01, 2012 at 20:07 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found