Better post on MooseX::Declare method signatures

So here is a better description of my problem, with simplified code examples.

First, the Holiday date checker that works (yes I know there is DateTime event classes and all that and I should use that framework, but I just wanted something that worked right away).
Continue reading



Okay, two lessons. No, three. First iron man perl planet rocks. Second, from now on push up code examples with my code problems. Third, I need to turn off moderation on this blog, since the spam filter seems to work pretty well.

I’m working up an example of the problem I had with DateTime and my attempts to solve it, and I’ll fold in the suggestions I got on my previous post (especially if they solve the problem!)

I used perl today, and I can’t figure out how to get my paper man icon.

I used perl today. Moose. I ran into a problem. It was annoying. I am way too stressed and tired to blog more. But I will anyway, secure in the knowledge that no one reads this blog but google’s spiders.

Okay anyway I used MooseX::Declare, and couldn’t get the method signature stuff to work. I did something like

method weekend_or_vacation (DateTime $dt){
  # check if weekend or vacation
  # with vacation being the tricky bit
  if($vacation || $weekend){
   return 1;
    return 0;

But MooseX::Declare kept complaining that it didn’t know what DateTime was. I scanned the tests in t and sure enough, they all test simple things like Str and ArrayRef and so on, but none of the more magical parts of type checking.

I eventually solved it the old fashioned way by puking if the argument wasn’t a DateTime, but I’d rather do it the method signature way.