#!/usr/bin/perl # Formatting ouput !!!! # otherwise known as the printf statement use strict; my $a=234; my $b=12; my $f1=123.4567; my $name="Joe"; my $grade=65; # %10d allocates 10 spaces for an integer, justifies right # %-10d allocates 10 spaces for an integer, justifies left # %10.3f allocates 10 spaces for a floating point, 3 digits after the decimal # %-10s allocates 10 spaces for a string, left justifies # %10c allocates 10 spaces for a character, justifies right . Expression must # be specified as an ASCII number. printf ("The numbers are %-10d%-10d %10d\n",$a,$b,$a+$b); printf ("The floating point number is %-10.2f\n",$f1); printf ("The string is %-10s\n",$name); printf ("Your grade is %-4c\n",$grade); for($grade=65;$grade<105;$grade++) { printf("The character is %c %d\n",$grade,$grade); }