
PPrint - Programmable sprintf. Allows you to associate functions to directives and supplies fairly powerful default directives.

use PPrint;
pprint("~2r", 8) => "1000"


PPrint provides a number of default directives.
~RADIX,MINCOL,PADCHAR,COMMAINTERVAL,COMMCHAR:;!R
Generic integer formating.
Parameters:
RADIXSpecifies the radix to use, values between 1 and 36 (inclusive) are allowed. Defaults to 10.
Minimum numbers of columns to use. Defaults to 0.
If the length of the number is less than MINCOL extra PADCHAR chars will be added to the left of the string in order to make it MINCOL columns long. Defaults to '0'.
Specifies how many chars should be between commas. Default is 3.
COMMACHARSpecifies which character to use instead of ',' when splitting a large number. Default is ','.
Flags:
:Seperate the number using COMMACHAR chars at intervals COMMAINTERVAL chars.
;Always put the sign of the number. The effect of this flag is to add a '+' to positive numbers.
!Add padding chars to the right instead of the left.
~MINCOL,PADCHAR,COMMAINTERVAL,COMMACHAR:;!D
Same as R directive with RADIX = 10.
~MINCOL,PADCHAR,COMMAINTERVAL,COMMACHAR:;!O
Same as R directive with RADIX = 8.
~MINCOL,PADCHAR,COMMAINTERVAL,COMMACHAR:;!X
Same as R directive with RADIX = 16.
~MINCOL,PADCHAR,COMMAINTERVAL,COMMACHAR:;!X
Same as R directive with RADIX = 2.
~REPEAT,TYPEn
Prints newlines.
Note that this directive consumes no elements from the arg list, unless 'v is used for REPEAT or TYPE of course.
Parameters:
REPEATSpecifes how many newlines to write. Default is 1.
TYPESpecifes which type of newline to write. 'u => unix (chr 0x0A), 'd => dos (chr(x0D) . chr(0x0A)), "m" => mac (chr 0x0D).
~REPEAT~
Prints tilde chars.
Parameter:
REPEATSpeciifes the number of tilde chars to print. Default is 1.
~S
Printing strings, just like sprintf("%s", $arg);
~INDENT_STYLE,PURITY,USEQQ,TERSE,DEEPCOPY,QUOTEKEYS,MAXDEPTH A
Print with Data::Dumper. see the Data::Dumper man page for what the various options mean.

One of the main reasons PPrint was written was to provide a way to customize how data should be printed, to this end PPrint can be extended to understand new directives.
FIXME: Describe it here. In the mean time look at the tilde and n directives.

Ideas liberally taken from Common Lisp's format directive.