I don't know a tutorial, just the man-pages.

But here comes a short explanation:

printf take a pattern string and a list of value, to fill into the pattern.
So the basic form is:

printf "pattern", value, value, value;

This pattern can hold any kind of text, including newlines, if you put it between doubles.
The pattern contains a placeholder for each value in the list.

The placeholders look like %n.mt, where the % is the begin of the placeholder, n is the length, m is the decimals if you have a number and t is the type of value.

n and m are optional, t can be one of a long list of which are s,d,f some examples.
s is for strings, d is for integers and f is for floats.
The complete list and further info can be found here

Transforming your example to this gives:

printf "%18s %18s %18s\n", $ip_date_time[$i]{ip}, $ip_date_time[$i]{date}, $ip_date_time[$i]{time};

update: added link to perlfunc:sprintf

update 2:there is a tutorial in the tutorial section (where else :-): Using (s)printf()


In reply to Re: Using printf by busunsl
in thread Using printf by nysus

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.