in reply to Moose not passing object to triggered method

When I try your code (with minor modifications so it'll compile) I get an exception from Moose: "Trigger must be a CODE ref on attribute".

The reason is that trigger => \&_get_future_events('existing_events'), first calls sub _get_future_events with the single argument 'existing_events' (which is the Dumper output you're seeing), and then takes a reference to its return value, and assigns that to trigger.

So you either need to write trigger => \&_get_future_events, to assign a reference to sub _get_future_events to trigger, or, if you really need to pass an extra argument to _get_future_events, you could do something like trigger => sub { _get_future_events(@_,'existing_events') },.

Replies are listed 'Best First'.
Re^2: Moose not passing object to triggered method
by nysus (Parson) on Mar 22, 2016 at 14:36 UTC

    Putting in the anonymous subroutine with sub {} for the trigger did the trick. Thanks!

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks