Loading ...
Sorry, an error occurred while loading the content.

printf/sprintf Order of Arguments

Expand Messages
  • rookt8zking
    In the sprintf documentation under topic Order of Topics , I tried the first two statements (both in the code below). The second did not produce the results
    Message 1 of 1 , Nov 14, 2011
    • 0 Attachment
      In the sprintf documentation under topic "Order of Topics", I tried
      the first two statements (both in the code below). The
      second did not produce the results expected. When I added code to follow
      a progression, it appeared that the form *n$.*
      just made WIDTH and PRECISION equal. In parentheses are the results that
      I thought would result. For example, in the
      second statement the * should not have moved in the argument list and
      remained at 2. If this is a BUG, I would appreciate
      an experienced user to report it. I read perlbug, and am reluctant to
      report a bug at this point.

      printf("Order of Topics:\n" .
      ' %%4$*3$s <%4$*3$s>' . " (width is 3 but expands to 6)\n" .
      ' %%4$*3$.*s <%4$*3$.*s>' . " (3.2, < Ma> BUG?)\n",
      2, 'Bartholomew', 3, 'Maggie');
      printf ' %%3$*1$.*s <%3$*1$.*s> (7.7, < Homer>)' . "\n", 7, 2, "Homer";
      printf ' %%*1$.*s <%*1$.*s> (7.7, < Homer> BUG?)' . "\n", 7, 2,
      "Homer";
      printf ' %%*.*s <%*.*s> (7.2, < Ho>)' . "\n", 7, 2, "Homer";
      printf ' %%2$*1$.*s <%2$*1$.*s> (2.2, <Ho>)' . "\n", 2, "Homer";
      printf ' %%*1$.*s <%*1$.*s> (2.2, <Ho> BUG?)' . "\n", 2, "Homer";

      Thanks
    Your message has been successfully submitted and would be delivered to recipients shortly.