How do I use a variable as a regex modifier in Perl?

前端 未结 4 2015
予麋鹿
予麋鹿 2020-12-11 17:13

I\'m writing an abstraction function that will ask the user a given question and validate the answer based on a given regular expression. The question is repeated until the

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 17:23

    You might also like the qr operator which quotes its STRING as a regular expression.

    my $rex = qr/(?$mod)$pattern/;
    $isValid =  =~ $rex;
    

提交回复
热议问题