in reply to A quick date swap from a string

You're use of $date is unlikely to be what you intended. Assuming the second my $date; isn't supposed to be there, we're left with:
sub num_month{ my $date = shift; ... foreach ...{ my $date = ... # <----this is a new $date scalar, which does not +exist outside of this foreach loop } return $date; #<----this is the $date from before the foreach loop +-- ie, exactly what was passed to the sub }

You can see the behavior by running this short script:
use strict; use warnings; my $test = &GO(1); print $test; sub GO{ my $val = shift; foreach (0..10){ my $val += $_; print $val . "\n"; } return $val; } 0 1 2 3 4 5 6 7 8 9 10 1