"Thanks for a very helpful reply."

You're very welcome. I'm always happy to help those who are eager to learn.

"I did have ... forgot to include it ... Sorry, first post but will remember in future."

That's fine and no need to apologise. My first post, a dozen years ago, was a complete mess: it took me several edits to clean it up.

When I don't know what version someone is using, I'll usually default to code that works in v5.8. Had I known that you were using the current latest, v5.36, I would've made a few more suggestions.

A simple one is say(), which has been around since v5.10. That saves you having to tag "\n" onto the end of print statements: not always what you want, but often is.

Of more recent vintage is "subroutine signatures". That's been flagged as experimental for quite a few versions, but no longer in v5.36. My suggested change for oddDigitSum() could have been written as:

sub oddDigitSum (@nums) { my @ans; for (@nums) { ...

When writing code just for myself, I typically use the latest version. If others are involved, I sometimes need to wind that back (or at least advise what newer features I'm using that require that version).

The online documentation, https://perldoc.perl.org/perl, shows the latest version; it does provide easy access to earlier versions. I'd suggest using that while you're learning; although, I would recommend staying away from experimental features: do read about them; don't use them in code, as many may change or even be removed; wait until they become stable.

— Ken


In reply to Re^3: Newbie question by kcott
in thread Newbie question by oldB51

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.