do_something(@compare) if grep { $test =~ $_ } @compare; #### use List::Util 'first'; do_something(@compare) if first { $test =~ $_ } @compare;