P, Pe, Pa, Pae Safer, General Format + Print sub
Version "1.0.9"
Combined printf, sprintf & say in 1 routine (almost). Can safely handle *args* to formmatted strings that are 'undef' & will print '(undef)' in place of the output. It knows how to print simple references and does so automatically rather than HASH=(0x235432), at the 1st level, it will print the contents of the hash: {none=>0, one=>1, two=>2}. Meant for use in development and as debug aid. Made executable and run, it does a small self-demo/test. Pod-documentation also builtin.
While designed with development in mind, isn't limited to such.
It combines features of printf, sprintf, and say: printing to strings if its output is assign to something, adding newlines when output is not to a string, ignoring a single extra newlines if added, allowing suppression of the auto-newline using the Unicode-control char "\0x83" "Don't break here".
Any items printed as strings that are undef -- will print '(undef)'.
Note, values given as args to a formatted print statement, are checked for undef and substitute "(undef)" for undefined values. If you print vars as numbers, this has the side effect of causing runtime format errors, so best to print as strings to see 'undef'. While usable in any code, it's use was designed to save typing, time and work of undef checking, newline handling, and doing the right thing with given input. It may not be suitable where speed is important. Hidden (but documented) feature: inserting the 'NO BREAK HERE' control- char (\x83) as the last char of a string will suppress a 'break' (newline) where it normally would be added.
To install P, copy and paste the appropriate command in to your terminal.
cpanm
cpanm P
CPAN shell
perl -MCPAN -e shell install P
For more information on module installation, please visit the detailed CPAN module installation guide.