If anyone wants to know what I found that fixed this problem:
The problem I was having is that @FIXES was not being emptied out. It was actually quite simple and since I am new took me forever to find. SO I added in a line of @FIXES=""; and it fixed the issue. I also took out all of the chomps as I learned that is not what I was looking for.
here is what that part of the script looks like now. The part I fixed is now in BOLD RED
#Team Workstation hotfixes Section
print "Backing up old twshotfixes.txt... \n";
rename ("C\:\\perl_scripts\\srvinfopc\\txtfiles\\TWS\\tws hotfixes.txt", "C\:\\perl_scripts\\srvinfopc\\txtfiles\\TWS\\bac\ \ twshotfixes.bac") || die "Cannot rename twshotfixes.txt: $!";
open (TWSINPUT, "C\:\\perl_scripts\\srvinfopc\\txtfiles\\TWS\\twss rvinfo.txt") or die "I could not open twssrvinfo.txt";
($WAIT_NAME, $WAIT_FIX, $WAIT_DRIVE) = (0,1,2);
open (TWSOUTPUT, ">>C\:\\perl_scripts\\srvinfopc\\txtfiles\\TWS\\tw shotfixes.txt") or die "I could not open twshotfixed.txt";
$CUR_STATE = $WAIT_NAME;
@FIXES;
while(<TWSINPUT>)
{
if($CUR_STATE == $WAIT_NAME && /^Server\ Name\:\ (.+)\n/)
{
print TWSOUTPUT "\n";
print TWSOUTPUT "$1";
$CUR_STATE = $WAIT_FIX;
}
elsif($CUR_STATE == $WAIT_FIX && /^Network\ Error\ (.+)\n/)
{
print TWSOUTPUT " $1\n";
$CUR_STATE = $WAIT_NAME;
}
elsif($CUR_STATE == $WAIT_FIX && /^Hotfixes/)
{
$CUR_STATE = $WAIT_DRIVE;
@FIXES="";
}
elsif($CUR_STATE == $WAIT_DRIVE && /^Drive/)
{
$CUR_STATE = $WAIT_NAME;
print TWSOUTPUT "@FIXES\n";
}
elsif($CUR_STATE == $WAIT_DRIVE && /^Network/)
{
$CUR_STATE = $WAIT_NAME;
print TWSOUTPUT "@FIXES\n";
}
elsif($CUR_STATE == $WAIT_DRIVE && /^Protocols/)
{
$CUR_STATE = $WAIT_NAME;
print TWSOUTPUT "@FIXES\n";
}
elsif($CUR_STATE == $WAIT_DRIVE && /\[(.+)\]\:/)
{
push (@FIXES, ",$1");
}
else
{
# die "INVALID DATA:$_";
}
}
close TWSINPUT;
close TWSOUTPUT;