Short on time this week, so just a skeleton of a post about Perl Weekly Challenge 259
Task 1 is a variation on Fizz Buzz. Count days, but skip over weekends and holidays. Use the DateTime
module to snarf up date strings (I love the smell of ISO8601 in the morning) and ignore pesky thoughts about leap years and daylight saving time. Play the Bee Gees Holiday on repeat.
Task 2 is a parsing problem. We could go all computer-science on it and write some kind of lexical tokenizer and grammar with a recursive descent parser. Or we could go hack-orific with regular expressions and obscure Perl features. I think you know where I'm going with this. You'll need this note on the flip-flop operator.
The solutions are on Github.
Top comments (1)
I mean, the great thing about the
DateTime
module is you don't have to worry about leap years and daylight saving time. If you're just adding days, DST doesn't come into play, andDateTime
handles the leap year calculations for you!