Since
unpack returns strings of zero length, you can check with
length:
use warnings;
use strict;
printf("%-11s %-27s %9s %11s","Date","Description","Incoming","Outgoin
+g\n");
my $x = 0;
my $tot;
my $totex;
while (<DATA>) {
if ($x==0) {$x++;next;}
my ($date,$des,$inc,$exp) = unpack("A10 A27 A10 A*", $_);
$inc = 0 unless length $inc;
$exp = 0 unless length $exp;
printf("%-10s %-27s %10.2f %10.2f\n",$date,$des,$inc,$exp);
$tot += $inc;
$totex += $exp;
}
printf("%38s %10.2f %10.2f","Totals",$tot,$totex);
print "\n";
__DATA__
Date Description incoming outgoing
01/24/2001 Zed's Camel Emporium 100.00 1147.99
01/28/2001 Flea spray 24.99
01/29/2001 Camel rides to tourists 235.00
01/31/2001 avage1 125.00
01/20/2001 carpe diem 20.00 23.00