152

Input/Output
Output using Printf

  • Data may be formatted and then output using the printf() function

      printf( FILEHANDLE FORMAT, LIST );

  • Same syntax as the "C" printf function (supports all stdio "%" constructs)

      $pi = 3.14159;
      $i = 42;
      printf( FH, "Stuff: %.2f, %d, %s\n", $pi, $i, "Hi" );

  • Type "man printf" on any UNIX machine (or, see "PP 2nd ed" page 222)