in reply to set the first day of last month to 1

You need to clone() $first:
... my $last = $first->clone()->add( months => 1 )->subtract( days => 1 ) +;
Otherwise $first and $last will be the same object.