in reply to Is there any way to put regex modifiers into a variable?
for sure davies's answer is wiser but maybe you are interested to know that also the feared eval string can accomplish the taske:
perl -e "$opts = 'io'; $rex = eval qq(qr/aka/$opts); print 'match' if +'ALAKAIA' =~ $rex" match
PS infact eval is powerful but dangerous: consider at least to check what was passed in following the good principle never trust user input that can be also read as never trust user or just never trust ;=)
my $opts = $ARGV[0]; die "never trust user input" unless $opts=~/^[msixpodualn]+$/; ...
L*
|
|---|