I'm not exactly a super expert or anything, but this script might get you where you want to go. Beware, I've only done minimal testing, and just on the data you provided. It also comes with the caveat (as has been previously mentioned) that it'll very much depend on the size of these files. However since you are reading them into memory in your initial script, its probably going to be alright.
#!/usr/local/bin/perl
use strict;
use warnings;
my $resfile = shift;
my $csafile = shift;
open(RESFILE, "$resfile") or die "unable to open $resfile: $!\n";
open(CSAFILE, "$csafile") or die "unable to open $csafile: $!\n";
open(OUTFILE, ">outfile") or die "Can't open the outfile: $!\n";
my %REShash;
#concatenate number and id for (hopefully) unique hash key
while (<RESFILE>){
/([A-Z])\s(\d+)\s([0-9a-zA-Z]+)/;
my $currentID = $3.$2;
$REShash{$currentID}=$1;
}
while(<CSAFILE>)
{
chomp;
my @record = split (/,/, $_);
#concatenate all parts of the record to get same formated hash key
my $currentId= $record[0].$record[3].$record[4];
if (exists $REShash{$currentId}){
print OUTFILE join(',', @record)."\n";
}
}
Also, what is being printed to the "outfile" is in the form of what I believe you are calling the CSAFILE (I may have those two switched around), fyi