Click here to get back home

printf doesn't do right justify

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
printf doesn't do right justify Daniel Cutter 03-09-2008
Posted by Daniel Cutter on March 9, 2008, 8:04 am
Please log in for more thread options
I thought that printf would allways right justify numbers, unless told
to do differently (with '-'). perlfunc doesn't tell.

#!perl
use strict;
use warnings;
printf("%2.1f\n", 12.3);
printf("%2.1f\n", 4.5);
printf("%02.1f\n", 6.7);

The results are:
12.3
4.5
6.7

But I expected:
12.3
4.5
06.7

What am I missing?

perl -v says:
This is perl, v5.10.0 built for MSWin32-x86-multi-thread
It's Win XP with all the patches

Regards
Daniel Cutter

Similar ThreadsPosted
Re: printf doesn't do right justify March 9, 2008, 8:32 am
justify text and PDF::API2 module February 17, 2005, 2:26 am
printf and variable length? October 25, 2005, 10:03 am
Using printf to modify scalars May 19, 2006, 8:44 am
printf: zero pad after the decimal a given amount March 30, 2008, 4:09 pm
Can't find right printf format April 28, 2008, 1:45 pm
printf + escape code May 22, 2008, 12:36 am
perl win32 & output of printf November 5, 2004, 4:15 pm
To store the output of printf into a variable... April 3, 2005, 9:56 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap