I said that I probably wouldn’t have time to get involved with the Perl Weekly Challenge every week and that has, unfortunately, proven to be the case. But I had a few free minutes earlier in the week so I decided to look at this week’s challenges. I’m glad I did because they seemed to… Continue reading Counting Weekends and Wrapping Text
Category: Programming
Perl Weekly Challenge – 2019-03-25
I’m not sure that I’ll have time to do these every week, but here are my answers to this week’s two Perl Weekly Challenges. Challenge #1 Write a script to replace the character ‘e’ with ‘E’ in the string ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ found in the string.
1 2 3 4 5 6 7 8 9 10 |
use strict; use warnings; use feature 'say'; $_ = 'Perl Weekly Challenge'; my $count = tr/e/E/; say; say "$count changes"; |
Nothing really complicated here. We can… Continue reading Perl Weekly Challenge – 2019-03-25
A Subtle Bug
Earlier this week, I saw this code being recommended on Stack Overflow. The code contains a nasty, but rather subtle bug. The version I saw has been fixed now, but I thought there were some interesting lessons to learn by looking at the problems in some detail. Let’s start by working out what the bug… Continue reading A Subtle Bug
Please Don’t Use CGI.pm
Earlier this week, the Perl magazine site, perl.com, published an article about writing web applications using CGI.pm. That seemed like a bizarre choice to me, but I’ve decided to use it as an excuse to write an article explaining why I think that’s a really bad idea. It’s important to start by getting some definitions… Continue reading Please Don’t Use CGI.pm
Fixing a Bug
I fixed a bug earlier this week. Ok, actually, I introduced a bug and then spent the next few hours tracking it down and fixing it – but that doesn’t sound quite so positive, does it? I thought it might be interesting to talk you through the bug and the fix. I should point out… Continue reading Fixing a Bug