Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I'd write that as:
return map { split / /, uc($_), 2 } @somearray;
If your construct was necessary, I'd use the the block form of map and I'd make explicit the $_ argument to uc. The implicit arg to uc distracts me most. These are just personal preferences.

The short and quick answer to your question is be merciful. For me, that you saw the need to ask predetermines the response.

Were I sitting in your place considering simplifying and expanding code, I would be considering the size, complexity and stability of my_sub[not sic]. If my_sub is stable, which is to say well defined, well implemented and well tested, then the issue is less significant; noone is apt to need to read the function body--an ideal toward which to strive. If the function is large, readability may be helped by the shorter version. If the function is complex, making it easy to read becomes more beneficial to a maintainer.

When I run into functions with which I am unfamiliar, I try to look them up; Perl's builtins are easy to look up so I'd likely just keep the map.

The Perl constructs which I think are more worth avoiding for readability's sake are those based on punctuation. I don't mean the variables found in perlvar, rather things like a dereferencing a hashref slice; I don't see that as so complex just difficult for the unacquainted to look up.

Be well,
rir


In reply to Re: Should I leave behind beautiful code or readable code? by rir
in thread Should I leave behind beautiful code or readable code? by MaxKlokan

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (10)
    As of 2014-10-01 13:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (18 votes), past polls