I imagine you problem is here:
foreach(@goods){
if (s/$caseid//){
$cases = $_;
}
}
You are taking $_ and removing 'CASE -' when it matches and then you copy the remainder in to $cases. Then you rewrite $cases in each iteration. I believe you want:
push(@cases,$_);
Some things that would make it helpful to other monks debugging you problem:
check the success of your open's - I can not stress how important this is
indentation - you have several different styles? of indentation going on
commenting - thank you for commenting your code - but I would also recommend lining up you comments with your code and using whitespace between sections to denote logical sections
grep
|
grep> grep clue /home/users/* |