use strict; use warnings; my $x="My name is VC"; my $y="myname"; $x =~ tr/ //d; print "Matched: >$1<\n" if $x =~ /(\Q$y\E)/i;