Script started on Thu Mar 13 07:27:16 2003 ***venkman-> cat sprintf.p @a = ("UNI", "Panthers", "SPRING!!!"); print "\n 1 2 3 4 5\n" . "12345678901234567890123456789012345678901234567890\n"; foreach (@a) { $str = $_ . " " . length $_; for ($i = 1; $i <= 4; $i++) { print sprintf "%-15s", $str; } print "\n"; } print "\n"; ***venkman-> perl sprintf.p 1 2 3 4 5 12345678901234567890123456789012345678901234567890 UNI 3 UNI 3 UNI 3 UNI 3 Panthers 8 Panthers 8 Panthers 8 Panthers 8 SPRING!!! 9 SPRING!!! 9 SPRING!!! 9 SPRING!!! 9 ***venkman-> ls -l sprintf* -rw-r--r-- 1 jacobson cns_fac 327 Mar 13 07:26 sprintf.p -rw-r--r-- 1 jacobson cns_fac 367 Jun 29 2001 sprintf.pl -rw-r--r-- 1 jacobson cns_fac 0 Mar 13 07:27 sprintfExample.script ***venkman-> cat sprintf.pl print "\nWhat is the monthly sales amount? "; $totalMonthlySales = <>; chomp $totalMonthlySales; $bonus = .125 * $totalMonthlySales; $roundedBonus = sprintf "%.2f", $bonus; print "\nYour bonus on last month's sales of $totalMonthlySales is: " . "$roundedBonus dollars.\n\n"; print "\nWithout using sprintf, your bonus look like this: $bonus \n\n"; venkman-> perl sprintf.pl What is the monthly sales amount? 2340.75 Your bonus on last month's sales of 2340.75 is: 292.59 dollars. Without using sprintf, your bonus look like this: 292.59375 venkman-> Control-d (exit) Script done on Thu Mar 13 07:29:37 2003