... my $sumcredits; while (my $pimrpt = ) { ... $sumcredits+= $credits; ... } print "The sum of credits is $sumcredits\n";