in reply to returning matched word from string

Can you explain a little more, please? In particular (and maybe only because it's been a long day), I don't understand:

I added the word CPLD to my string which is the third word in the txt file.

update for clarity: As "CPLD" is the second word in $teststring, I'm confused.

Based on a WAG, however, please note that for a match, your $rawdata will have to contain the complete sentence in $teststring.

So please post a reasonably small sample of your acrolist.txt.

Your script, minus one of the redundant declarations of my $newrawdata compiles and runs for me when run against a text file:

Hello CPLD this is just a test that I have created now. Bye, CPLD! This string does not have the magic accronym.

Compilation and execution produces the expected output, to wit,

pl_test$ perl -c 699458.pl 699458.pl syntax OK ~/pl_test$ perl 699458.pl Hello CPLD this is just a test that I have created now. Hello CPLD this is just a test that I have created now. Bye, CPLD! This string does now have the magic accronym. You have a MATCH! Hello CPLD this is just a test that I have created now.