Is this anything at all like you have in mind?
Code:
#!/usr/bin/perl -w
# Example: ./myscript 4
# queue thresh dropped [cos-map]
my $COS = $ARGV[0];
print "\n";
open(INFILE, "/home/file.txt") || die "Can't open file for read: $!";
while (<INFILE>){
($var1, $var2, $var3) = split /\s+/;
$QT = ($QT += $var1);
$TT = ($TT += $var2);
$DT = ($DT += $var3);
write;
}
# Note: leave the periods ( . ) as they are needed.
# Output text header
format STDOUT_TOP =
queue thresh dropped [cos-map]
.
# Output text body
format STDOUT =
@##### @##### @##### @#####
$var1,$var2,$var3,$COS
.
$~ = "STDOUT_TOTALS";
write;
# Output text footer
format STDOUT_TOTALS =
-------------------------------------
@##### @##### @#####
$QT,$TT,$DT
.
####End