Skip to content

Instantly share code, notes, and snippets.

@worr
Created July 5, 2013 18:11
Show Gist options
  • Save worr/5936237 to your computer and use it in GitHub Desktop.
Save worr/5936237 to your computer and use it in GitHub Desktop.
matches some dates
my $mos = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ];
my $now = localtime;
my ($prev_month, $cur_month, $cur_day) = ($mos->[($now->mon() - 1) % 12], $mos->[$now->mon()], $now->mday());
map { print $out_fh $_ } grep { /(?:$cur_month|(?(?{$cur_day == 1})($prev_month)|$cur_month))\s+(?(1)(?:(?(?<=Feb\s)(?:28|29))30|31)|(?:$cur_day|(??{$cur_day - 1})))\b/ } <$in_fh>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment