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.
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 overload.pm 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
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.
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.
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:
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.
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.
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.
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.
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.
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.
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.
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!).
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?
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.
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.
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.
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 fimfiction.net 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.
Let's look at the XSPF playlist format. It's a pretty simple XML-based file format.
<?xmlversion="1.0"encoding="UTF-8"?><playlistversion="1"xmlns="http://xspf.org/ns/0/"><title>80's Music</title><trackList><track><title>Take On Me</title><creator>A-ha</creator><location>https://example.com/music/01.mp3</location></track><track><title>Tainted Love</title><creator>Soft Cell</creator><location>https://example.com/music/02.mp3</location></track><track><title>Livin' on a Prayer</title><creator>Bon Jovi</creator><location>https://example.com/music/03.mp3</location></track></track></trackList></playlist>
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.