in reply to How can I change substitution options within a program?

Build up your regular expression programatically, and use the (?i-xsm) or (?-xism) constructs (documented in perlre).

In other words....

my $insensitive = '(?i-xsm)'; my $sensitive = '(?-xism)'; my $target = "Abcde"; foreach my $re_switch ( $insensitive, $sensitive ) { if( $target =~ m/$re_switch([a-z])/ ) { print "$1\n"; } }

And the output...

A b

Dave