G'day Neutron Jack,

While I agree the documentation for printf is not really up to scratch; I also think your comments are based on a false premise.

The documentation shows four forms that the function can take; two have no LIST (printf FILEHANDLE and printf):

$ perl -Mstrict -Mwarnings -E '$_ = 42; printf STDERR' 42 $ perl -Mstrict -Mwarnings -E '$_ = 42; printf' 42

However, the documentation uses list and LIST in an ambiguous manner; furthermore, use of the lowercase list is, at best, misleading (but, more likely, an error).

list (lowercase)

An equivalence is shown:

print FILEHANDLE sprintf(FORMAT, LIST)

followed by "... The first argument of the list will be interpreted as the printf format."

My best guess is that this is supposed to refer to the list of arguments to sprintf — but that's all that is, a complete guess. The documentation would be greatly improved if that was clarified.

LIST (uppercase)

The "If you omit the LIST, $_ is used; to use FILEHANDLE without a LIST, ..." text follows the sprintf ambiguity. I believe this refers to the two printf forms (shown at the top) which do not contain LIST. Without the confusing text before it, I think would be somewhat more obvious; however, additional clarification might not go astray here either.

-- Ken


In reply to Re: $_ as default printf arg fails by kcott
in thread $_ as default printf arg fails by Neutron Jack

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.