I actually code the other way around. I do for example something like this:
sub foo { #takes 2 arguments, a scalar(number between x and y) and a hashref #make the scalar jump through a hoop #make a copy of the hash referenced by the hashref #set the hashref on fire #multiply each value in the newly created hash by the scalar #return a reference to said newly created hash }
And the next step is to actually turn said train of thought into code, which would yield something like this:
sub foo { #takes 2 arguments, a scalar(number between x and y) and a hashref my($scalar, $hashref) = @_; unless(($scalar =~ /^\d+$/) && ($scalar >= 7) && ($scalar <= 25) && +ref($hashref) eq 'HASH')) { print "you're an idiot!\n"; return; } #gee, maybe i could be a little more informative here? #make the scalar jump through a hoop make_jump_through_hoop($scalar); #make a copy of the hash referenced by the hashref my %newhash = %{$hashref}; #set the hashref on fire set_on_fire($hashref); #multiply each value in the newly created hash by the foreach my $key (keys(%newhash)) { $newhash{$key} = $newhash{$key} * $scalar; } #return a reference to said newly created hash return \%newhash; }
So in this case(usually when I'm doing something really complicated(for me anyway)) code follows comment, not the other way around.


Remember rule one...

In reply to Re: The art of comments: (rave from the grave) by Forsaken
in thread The art of comments: (rave from the grave) by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.