foreach (@uniquekey) { if (/something/) { push(@($_),$_); } }