Skip to content

Instantly share code, notes, and snippets.

@s1037989
Created July 26, 2023 22:22
Show Gist options
  • Save s1037989/dba3217fddba2bc61f4c77f2f24185e7 to your computer and use it in GitHub Desktop.
Save s1037989/dba3217fddba2bc61f4c77f2f24185e7 to your computer and use it in GitHub Desktop.
reduce a list of dates to those less than X
$ perl -Mojo -MTime::Piece -E 'say c(qw(2022.11 2022.12 2023.01 2023.02 2023.03 2023.04 2023.05 2023.06 2023.07))->reduce(sub{push @$a, $b if Time::Piece->strptime($b, "%Y.%m") < Time::Piece->strptime($ARGV[0]||localtime->strftime("%Y.%m"), "%Y.%m"); $a}, c())->join(",")' 2023.02
2022.11,2022.12,2023.01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment