$ perl -wle' $string = "123webmaster123"; $name = "*webmaster*"; $name =~ s/\*/.*/g; if ($string =~ m/^$name$/i) { print qq{"$string" matches "$name"} }' "123webmaster123" matches ".*webmaster.*" $