Maybe some more tests to make sure we've covered all the edge cases:
    for my $line ( <DATA> ) {
        chomp $line;
        my( $check_dns, $san_dns, $must_match ) = split ' ', $line;

        my $match = dns_match( $check_dns, $san_dns );


        is $match, $must_match, "$san_dns ~ $check_dns";
    }

    __DATA__
    abc.foo.com     *.foo.com       1
    def.abc.foo.com *.foo.com       0
    foo.com         *.foo.com       0
    abc.foo.com     abc.foo.com     1
    foo.com         *.com           1
    abcdfoo.com     *.foo.com       0