#!/usr/bin/perl use strict; use warnings; my %qrs = ( string1 => 'foo', string2 => '(xism)', regex => qr/foo/, 'regex?' => '(?-xism:foo)', ); while( my( $key, $regex ) = each %qrs ) { print "'$key' "; print $regex =~ /\(\?\-xism:/ ? 'YES: ' : 'no: '; print $regex; print ' (and matches)' if 'foo' =~/$regex/; print "\n"; }