On Mon, 5 Sep 2016 21:23:54 -0500 David Nicol <davidnicol@gmail.com> wrote: > I agree. We already have a way to "ask the lhs whether it matches" and > that system is called method dispatch. > > sub UNIVERSAL::DumbMatch{0} > sub DumbMatchOnOdd::DumbMatch{ [0,1]->[$_[1] % 2] } > ... > $SomeObjectOrOther->DumbMatch($PretzelPattern) and say "got a > pretzel"; Well, almost. That is a bit dirty and pollutes the UNIVERSAL namespace. Nicer would be if perl had notations for "try to call this method but if it doesn't exist, yield some sentinel falsey value like undef or empty list". -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next