Perl Weekly Challenge 202: Consecutive Odds and Widest Valley

These are some answers to the Week 202 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a few days from now (on February 5, 2023 at 23:59). This blog post offers some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 1: Consecutive Odds

You are given an array of integers.

Write a script to print 1 if there are THREE consecutive odds in the given array otherwise print 0.

Example 1

Input: @array = (1,5,3,6)
Output: 1

Example 2

Input: @array = (2,6,3,5)
Output: 0

Example 3

Input: @array = (1,2,3,4)
Output: 0

Example 4

This Week in PSC (095)

A busy meeting today, we talked about quite a few things:

  • Smartmatch deprecation continues. Some upstream PRs have been raised, awaiting CPAN releases
  • Refaliasing might be able to be deëxperimentalized if we add a warning on the currently-failing closure capture cases
  • RFC0013 highlights a deficiency in the API shape. Perhaps an opt-in new calling convention is required to make it more flexible. Paul will write another post to the mailing list with more detail
  • Mithaldu's objection to the suggestion to deprecate map EXPR, LIST suggests that maybe a more powerful debugger "run until next statement" command would be good
  • The interaction of List::Keywords + autovivification highlights the overall problem with highly-pluggable extensible systems - sometimes extensions conflict. We just have to keep this in mind and not have too high expectations that "everything will be fine if we load 20 different plugins"
  • That said, maybe there are some CPAN extensions that ought to be part of the core language - autovivification for example
  • We've run out of devel release volunteers now. We need some people to volunteer for 5.37.9, .10, .11, (maybe .12?). Also maybe 5.38.0

My Favorite Modules: PerlIO::via

OK, I confess: PerlIO::via is not a module that I use every day. It allows you, easily, and with minimal code, to modify an I/O stream before it gets to the reader of the stream. or after the writer has written it. All you do is write (say) My::Module conforming to the parts of the PerlIO::via interface you need, and provide it to the second argument of open() or binmode() as ':via(My::Module)'. How cool is that? And how cool is a language that lets you do that with a minimum of fuss, bother, and code?

I encountered this when trying to modify (OK, hack) the behavior of a large and complex hunk of Perl not under my control. Rummaging around in this turned up the fact that all file input went through a single module/object, which had an open() method. I realized if I could insert my own PerlIO layer into the input stream, I would have control over what the victim host code saw.

Perl Testing in 2023

With my open source work, I've historically taken an approach which relies more on integration testing than unit testing, but with some of my newer projects, I've tried adopting principles from $paidwork and applying them to my free software.

This is a quick run-down of how I'm structuring my test suite in newer projects. It's likely that many of my existing projects will never adopt this structure, but some may.

Perl Weekly Challenge 201: Missing Numbers

These are some answers to the Week 201 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

You are given an array of unique numbers.

Write a script to find out all missing numbers in the range 0..$n where $n is the array size.

Example 1

Input: @array = (0,1,3)
Output: 2

The array size i.e. total element count is 3, so the range is 0..3.
The missing number is 2 in the given array.

Example 2

Input: @array = (0,1)
Output: 2

The array size is 2, therefore the range is 0..2.
The missing number is 2.

Missing Numbers in Raku

Using Perl to prepare sequencing files to submit to NCBI's GEO

In the middle of a manuscript submission that requires sequencing data to be uploaded to NCBI's Gene Expression Omnibus.
This is a fairly standardized and (painful!) process that requires one to assemble their sequencing data (a collection of hundreds or thousands of files in the FASTQ format), put them in a single (very large) folder, compress them, generate md5 hashes and then upload them to GEO's FTP site.
There are a couple of tutorials available e.g. here and there that mostly cover the use case of one having assembled the files into a single fastq.
Our project used Oxford's Nanopore platform which store's its data as a series of fastq files, each holding a user defined number of sequences (in our case 2,000). Some of the experiments had generated an excess of 10M reads, so we are talking about a serious number of files to process:

  1. uncompress (if compressed)

  2. concatanate

  3. compress

  4. hash using md5sum

This Week in PSC (094)

PSC met today, all three of us attended.

We discussed:

  • HAARG's map my $x RFC. Overall thoughts are good, with one or two minor questions we'll add as comments.
  • Whether the additions to join() as part of RFC0013 should be gated by some sort of opt-in flag, so as to avoid surprises. Either a feature flag for the caller of join(), or a use overload import option.
  • Maybe renaming the RFC process itself (because of the ambiguity with IETF's RFC) and improving the numbering system. More discussion needed.

OTOBO supports the German Perl/Raku-Workshop

We are happy to announce that Rother OSS again supports the German Perl/Raku-Workshop as a sponsor.

Since 2011, Rother OSS GmbH, based in southern Germany and with a team throughout Germany, has relied on the combination of an open source ticket system and business services from experts. Specifically: consulting, development and support for the free OTRS versions.

Perl Weekly Challenge 200: Arithmetic Slices and Seven Segment Display

These are some answers to the Week 200 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on January 22, 2023 at 23:59). This blog post offers some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 1: Arithmetic Slices

You are given an array of integers.

Write a script to find out all Arithmetic Slices for the given array of integers.

An integer array is called arithmetic if it has at least 3 elements and the differences between any three consecutive elements are the same.

Example 1

Input: @array = (1,2,3,4)
Output: (1,2,3), (2,3,4), (1,2,3,4)

Example 2

Input: @array = (2)
Output: () as no slice found.

Arithmetic Slices in Raku

Util::H2O and More, during Ordinary Times


During the 2022 Perl Advent, in particular the entry for December 06; Perl Advent fans were introduced to a little module called Util::H2O.

A lot has already been said about Util::H2O, and this author uses it a lot in client and production code because it helps produce very clean and maintainable HASH reference heavy code. So much so, that he created the Util::H2O::More module to encapsulate some common tasks and additional capabilities for working between pure Perl data structures and blessed objects that have real data accessors, in a natural and idiomatic way.

Support for Generic Perl Data Structures

h2o is perfect for dealing with data structures that are made up of strictly HASH references, but it is often the case that useful data structures contain a mix of HASH and ARRAY references. For example, when using databases or web API calls returning JSON, it is often a list of records that is returned. This was the case of the example call that was in the December 06 Perl Advent 2022 article.

My Family and Other Fish (PerlayStation Part 2)

Faced with any problem, there are many potential approaches. This, I have realised, is amply illustrated by the members of my own family, further reinforcing the educational value of having one. I shall anonymise them for my own protection, and as a disclaimer also state that everything I say about them or anything at all is probably wrong. In fact I have already issued my daily, pre-emptive, unspecified apology to my wife. For me, game coding in Perl is no different.

Identify Problem

Regexp Delimiters

Perl lets you use almost anything as a regular expression delimiter. It is usual to use punctuation of some sort, but characters that match /\w/ can be used provided there is white space between the operator and the delimiter: m X foo Xsmx compiles and matches 'foobar'. In the presence of use utf8; you can go wild.

A query on the Perl 5 Porters Mailing List (a.k.a. 'p5p') a few days ago asked for opinions about appropriating the colon (':') as a delimiter for modifiers to the regular expression operators. This got me wondering about what regular expression delimiters were actually in use.

I scratched that itch by plowing through my local Mini CPAN, running everything that looked like Perl through PPI, and checking anything that parsed to an object of one of the relevant classes. A summary of the results is appended.

How to prevent an infinite loop

This loop (assuming you have an /etc/passwd and may read it) runs forever:

while () {
  open my $fh, '<:unix', '/etc/passwd' or die $!;

This loop terminates:

while () {
  open my $fh, '<', '/etc/passwd' or die $!;
  binmode $fh, ':unix';

Note that you will have to live with some extraneous output:
Too many open files at line 2.

Btw, you can make it loop forever again this way:

require POSIX;
while () {
  open my $fh, '<', '/etc/passwd' or die $!;
  binmode $fh, ':unix';
  POSIX::close fileno $fh;

The Perl Toolchain Summit is back in 2023!

After a three years pandemic-induced hiatus, it is my pleasure to announce that the Perl Toolchain Summit is happening again!

This year, for the thirteenth edition, we will be gathering again in Lyon, from Wednesday April 27 to Sunday April 30 2023, in the hotel Campanile Lyon Centre Part-Dieu. Participants will stay at the hotel, and work in the meeting rooms dedicated for the event.

The first rounds of invitations have been sent. We plan on having about thirty participants. We are always looking for sponsors (ask for our sponsor prospectus!).

This Week in PSC (093)

Paul, Philippe, and Rik had our regular call today to talk about perl5.

We put together some notes (at long last) for The Perl Foundation to use in their annual prospectus.

We talked about Math-Complex, and moving its issues into Perl5 GitHub. (A nice bit of work for anybody to do, but not groundshaking.)

We got back to the question of making Perl do SSL out of the box. Paul's question was, "Can we bundle the CPAN dists for doing this and basically CPAN-install them at the end of normal install?" Audacious, but plausible!

We talked about the upcoming release of v5.38. Sure, it's months away, but the various code freezes are approaching. What stuff needs work? One thing we did especially was review what experiments might be able to be deëxperimentalized. We talked about the refaliasing feature, which remains broken on closures, a total showstopper. Paul wonders if we can reduce the scope of how the feature can be used. For example: what if you must also use declared_refs?

Geizhals Preisvergleich sponsors the German Perl/Raku Workshop

In 2023, the German Perl/Raku Workshop will take place in Frankfurt am Main.
We are very happy to announce that long time Perl supporter Geizhals Preisvergleich sponsor the workshop.

Perl Weekly Challenge 199: Good Pairs and Good Triplets

These are some answers to the Week 199 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a few days from now (on January 15, 2023 at 23:59). This blog post offers some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Contrary to usual, I started with the Perl implementations this week (not having Raku installed on the computer where I started to work on the challenge). So I’ll present the Perl implementations first.

Task 1: Good Pairs

You are given a list of integers, @list.

Write a script to find the total count of Good Pairs.

A pair (i, j) is called good if list[i] == list[j] and i < j.

Example 1

Fosdem mini grants for 2023

One of the goals TPRF would like to achieve, now that conferences are becoming increasingly available in person, is to spread awareness of current Perl and Raku projects.

In support of this goal, TPRF will be issuing a limited number of mini grants of up to $300 to participants interested in holding Perl/Raku based talks in FOSDEM 2023 dev rooms. TPRF has made an intentional decision to not apply for a dev room, but to encourage talks to be given in other, non-language specific dev rooms instead. This will allow Perl and Raku to be shared with new audiences.

In addition, TPRF will have a 2 day stand at FOSDEM and are in need of volunteers to staff it. Stand volunteers are also eligible to apply for a mini grant of up to USD$300 to assist with the cost of attending.

To apply for a FOSDEM mini grant, please send a completed application to

If you have questions, please join our fosdem slack channel, leave a comment below, or send a message to

(Also on TPF news)

Benchmarking Rakudo releases. Is Raku Still slow?

Benchmarking Rakudo releases. Is Raku Still slow?


Around the first 'public' release of Perl 6 (The x-mas release) I wrote a module that uses the libgumbo from google to parse html5 webpages.

It was faster and more robust than the existing HTML::Parser module written in pure Perl 6. To be fair to the module, the full html5 norm is rather lenghtly to implement.

I was using this to parse my list of favorite fan fiction on and try to make some stats around them. It was still not super fast, like 0.5+ sec to parse one page (I have like 20+ pages of favorites). So each run of the script was rather slow.

At the time Perl 6 was still in stabilization phase and performance improvements were not really important. But after a while, it started to creep its ways out into Moar and Rakudo. So I wanted to see the improvement over the Rakudo release for my Gumbo module.

Building all Rakudo release

Creating a Simple DSL in Perl

Let's look at the XSPF playlist format. It's a pretty simple XML-based file format.

  <?xml version="1.0" encoding="UTF-8"?>
  <playlist version="1" xmlns="">
    <title>80's Music</title>
        <title>Take On Me</title>
        <title>Tainted Love</title>
        <creator>Soft Cell</creator>
        <title>Livin' on a Prayer</title>
        <creator>Bon Jovi</creator>

The full specification has a lot more details, but for now, we'll just use those elements.

If we are building a Perl application that needs to allow less experienced users to write playlists in Perl, it might be useful to define a domain-specific dialect of Perl for writing playlists.

About is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.