RE: [PBML] Printf formatting
- Thanks, I apologize for not looking in perldoc sprintf. (I only looked
in perldoc printf)
Its very clear and I now have :
printf( FILEHANDLE "Test Case : %-51s PASSED\n", $FileName);
From: Randal L. Schwartz [mailto:merlyn@...]
Sent: Tuesday, 25 October 2005 9:37
To: Bobby Jafari
Subject: Re: [PBML] Printf formatting
>>>>> "Bobby" == Bobby Jafari <bobby.jafari@...> writes:Bobby> Hi all,
Bobby> printf ( FILEHANDLE "Test Case : %s PASSED\n" $FileName );
Bobby> I need the printed line to always be 70 characters long. I need
Bobby> PASSED to be right justified (i.e PASSED needs to be printed as
Bobby> characters 65 to 70.) I looked up the printf manpage but I didn't
Bobby> help much. Any idea's how this is done?
$ perldoc -tf printf
printf FILEHANDLE FORMAT, LIST
printf FORMAT, LIST
Equivalent to "print FILEHANDLE sprintf(FORMAT, LIST)",
that $\ (the output record separator) is not appended. The
argument of the list will be interpreted as the "printf"
See "sprintf" for an explanation of the format argument.
$ perldoc -tf sprintf
sprintf FORMAT, LIST
one or more of: space prefix positive number with a
prefix positive number with a plus sign - left-justify
within the field 0 use zeros, not spaces, to
prefix non-zero octal with "0", non-zero hex with "0x",
non-zero binary with "0b"
printf '<% d>', 12; # prints "< 12>"
printf '<%+d>', 12; # prints "<+12>"
printf '<%6s>', 12; # prints "< 12>"
printf '<%-6s>', 12; # prints "<12 >"
printf '<%06s>', 12; # prints "<000012>"
printf '<%#x>', 12; # prints "<0xc>"
What part of that 3rd example is not clear?
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095 <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl