in reply to Help understand why this grep does not work

you are overwriting @results in each loop and are only getting the last hits.

edit

better try something like push @results, grep {/$match/} @data2;

Cheers Rolf

( addicted to the Perl Programming Language)