my $str = join '', map "$_*", "a".."z"; my $re = qr/^$str$/; print "Matches\n" if "abc" =~ $re; print "Doesn't match\n" unless "zbc" =~ $re;