use strict; use warnings; my $text = 'Abcd'; my $match = 'abcd'; my $regex = qr/$match/; print "No match: '$text', '$match'\n" if $text !~ /$regex/i; print "/i match: '$text', '$match'\n" if $text =~ /$match/i; #### No match: 'Abcd', 'abcd' /i match: 'Abcd', 'abcd'