Checking for proper number of files in dir

Using Solaris 10 and sh.

I have three files.
mydirs.txt
/dir1/dir2/dir3
/dir4/dir5/dir6

mydirshave.txt
1
2

mydirsshouldhave.txt
2
2

For each directory listed in mydirs.txt I should have the number of files equal to mydirshouldhave.txt. But using -ls |wc -l- on the dirs I get what is in mydirshave.txt. So I want to error with dir3 as it is short. All three files will have the same number of lines. I know how to get the three files above. I am trying to find the best method to check for ones that do not have the correct number of files. I am not an expert but I put this together to try and get the point across further:

dir= `cat mydirs.txt`
shouldhave= `cat mydirsshouldhave.txt`
have= `cat mydirshave.txt`
;do
if test -d $dir
then
$shouldhave=$have GOOD
else
error BAD 

I don't have to bring in the mydirshave.txt files if I am doing the ls |wc -l in the script. Thanks in advance!

I notice you posted 4 days ago, any progress or do you still need a hand?

Sorry, I haven't gone through the post completely

dir= `cat mydirs.txt`

should be as

dir=`cat mydirs.txt`

( no space between = and ' )