In the
foreach loop, the
$_ variable is set implicitly, so the pattern match within
parse_datetime() will always 'work' whereas ...
in your
for loop, the
$_ variable remains unset, so the match always fails.
Try (local $_ = shift) =~ ... or +shift =~ .... in place of $_ =~ at the start of parse_datetime()
A user level that continues to overstate my experience :-))