in reply to grep the whole element in an array

I think you better parse file2 and file3 into hash of arrays. Something like:

my $file2 = { string11 => [ "AGCTAGCTG", "CAGAGTC" ], string123 => [ "AGCTGAAGA" ], string12 => [ "AGCGATTATCGA", "AGCATGAAGACC", "ACAGCATGACTA" ], ...... };

And same for file3. After that you can easly manipulate your data.