in reply to guidelines for inline coding

My top tip for using statement modifiers is this:

print, sum += $_ for @array;

That is, if you find yourself wanting to trace the loop, don't go through the pain of reformatting the loop as block scoped in order to print the iteration, just add the print with a comma as a line preceding the modified loop.

Then comment the added line out or just blow it away when your done debugging.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: guidelines for inline coding
by misterperl (Friar) on Sep 26, 2014 at 13:59 UTC
    Thanks monks for all of the insight and advice, it's all most appreciated. I guess bottom-line is as advised, the inline statements are only for simple cases. In general I want my code to look more like an sentance than code, like Englishizing:
    if ( $cat ) { $dog='onALert'; }
    to
    $dog='onALert' if $cat;
    its so much cleaner, easier to read. It would be even nicer if "is" could substitute for =", (sort of like SQL "is NULL") then:
    $dog is 'onALert' if $cat; $dog is 'sleeping' unless $cat;
    Nice! Thanks guys for the insight- I'm just syntax-surfing techniques to pretify my code...