in reply to The art of comments: (rave from the grave)

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...