in reply to Using printf

Read Appendix A of Effective Perl Programming. (Or say "man 3 printf" in a Linux/Unix shell ... might also help.)

Update: If you need to get the output into a text format (e.g., for redirecting into a file), do this (thanks to jmcnamara for the tip):

man 3 printf | col -b > printf.txt

The "col()" command will filter out all the terminal escapes for you.

Update: Why "man 3 printf"? Because there is a printf command, too, and you will get its man page when you just say "man printf". But you want the manpage on the printf C library call, so you have to use "man 3 printf" to indicate you want the printf entry from section 3 of the manpages, which describes (surprise) library calls. See "man man" for more details on the surprisingly useful man command.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

Replies are listed 'Best First'.
Re: Re: Using printf
by arturo (Vicar) on Jul 02, 2001 at 15:06 UTC

    And if you want to print out a nice troff formatted version of a man page (looks great on most printers), you can use the nifty -t switch:

    man -t printf | lpr

    (You need troff installed, but that should be there on any *nix-like OS worth having =)

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'