DEV Community

Bob Lied
Bob Lied

Posted on

PWC 259 Something I think's worthwhile if a parser makes you smile

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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (1)

Collapse
 
packy profile image
Packy Anderson

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, and DateTime handles the leap year calculations for you!

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay