my $flags = 'i'; my $string = "this is a tEst"; if ( $string =~ m/text/$flags ) { print "this worked\n"; }