Can't find right printf format

Discussion in 'Perl Misc' started by Hubert Gabler, Apr 28, 2008.

  1. Hello,
    my problem is very simple, but I cannot find the answer in "Learning
    Perl" nor in the manpages:
    Which FORMAT in printf makes the numbers 1,2,3,.. look like 001,002,003..?
    Hubert
     
    Hubert Gabler, Apr 28, 2008
    #1
    1. Advertising

  2. Steven M. O'Neill, Apr 28, 2008
    #2
    1. Advertising

  3. Hubert Gabler

    Ben Morrow Guest

    Quoth Hubert Gabler <>:
    > Hello,
    > my problem is very simple, but I cannot find the answer in "Learning
    > Perl" nor in the manpages:
    > Which FORMAT in printf makes the numbers 1,2,3,.. look like 001,002,003..?
    > Hubert


    perldoc -f printf says 'printf FILEHANDLE FORMAT, LIST' is equivalent to
    'print FILEHANDLE sprintf FORMAT, LIST' (with a caveat), so you need to
    look in perldoc -f sprintf. This contains a full list of the conversion
    specifiers supported by Perl.

    Ben
    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    Heraclitus
     
    Ben Morrow, Apr 28, 2008
    #3
  4. Hubert Gabler

    Uri Guttman Guest

    >>>>> "HG" == Hubert Gabler <> writes:

    HG> my problem is very simple, but I cannot find the answer in
    HG> "Learning Perl" nor in the manpages: Which FORMAT in printf makes
    HG> the numbers 1,2,3,.. look like 001,002,003..? Hubert

    FAQ

    perldoc -q pad

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Free Perl Training --- http://perlhunter.com/college.html ---------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
     
    Uri Guttman, Apr 28, 2008
    #4
  5. >...you need to look in perldoc -f sprintf.

    Thanks to all who gave me this hint. I simply overlooked the link from
    printf to sprintf. I promise to read the manpages more careful in the
    future before asking the experts!
    Kind regards,
    Hubert
     
    Hubert Gabler, Apr 29, 2008
    #5
  6. Hubert Gabler

    szr Guest

    Hubert Gabler wrote:
    > Hello,
    > my problem is very simple, but I cannot find the answer in "Learning
    > Perl" nor in the manpages:
    > Which FORMAT in printf makes the numbers 1,2,3,.. look like
    > 001,002,003..? Hubert


    %03d

    This will give you 3 zero-padding digits (if you remove the zero from
    the format, it will be the same width, but space-padded instead.)

    --
    szr
     
    szr, Apr 29, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ben
    Replies:
    4
    Views:
    643
    Martin Ambuhl
    Jun 26, 2004
  2. whatluo

    (void) printf vs printf

    whatluo, May 26, 2005, in forum: C Programming
    Replies:
    29
    Views:
    1,303
  3. azza

    printf affects following printf/s

    azza, Oct 17, 2010, in forum: C Programming
    Replies:
    0
    Views:
    452
  4. Randy Kramer
    Replies:
    2
    Views:
    418
    Randy Kramer
    Jan 12, 2007
  5. guru
    Replies:
    8
    Views:
    296
Loading...

Share This Page