http://qs321.pair.com?node_id=675171


in reply to unconventional string substitutions

Another approach is to use embedded flags, it is possible to embed all the modifiers except /g and /c

#!/net/perl/5.10.0/bin/perl use strict; use warnings; use 5.010_000; my $string = 'This is perl, the Perl interpreter'; foreach my $flag ( '', 'i' ) { if ( my ($match) = $string =~ /(?$flag:(Perl))/ ) { print "$match\n"; } } Perl perl __END__

Update: also doesn't work with /c, add it above.