use strict; use warnings; my $chosen = 'some text'; my @array = (qr'some', qr'more', qr'text'); my $index = 1; if (defined $chosen && $chosen !~ /$array[$index]/) { print "\$array[$index] matches\n"; }