Perl Weekly Challenge 245: Sort Language

These are some answers to the Week 245, Task 1, 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 December 3, 2023 at 23:59). This blog post provides some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.

Task 1: Sort Language

You are given two arrays of languages and its popularity.

Write a script to sort the language based on popularity.

Example 1

Input: @lang = ('perl', 'c', 'python')
       @popularity = (2, 1, 3)
Output: ('c', 'perl', 'python')

Example 2

Input: @lang = ('c++', 'haskell', 'java')
       @popularity = (1, 3, 2)
Output: ('c++', 'java', 'haskell')

Sort Language in Raku

The Perl Toolchain Summit 2023 has a COVID Policy

The Perl Toolchain Summit is the annual event that brings together the key developers working on the Perl toolchain. The 13th summit (after a three year hiatus in 2020-2022) is in France this year, in late April.

It is, at its heart, an in-person event: about thirty people will spend four days in confined spaces, exchanging ideas and patches. And also droplets. To keep everyone safe, we have prepared a COVID policy.

This week in PSC (097) | 2023-02-10

PSC met today, just Paul and Philippe.

We discussed:

  • inclusion of TLS libraries in the core: we think we should just try the “dual life” path, and see where that gets us.
  • n-at-a-time map/grep: Paul suspects it’s impossible to properly disambiguate my ($var, ...) from the EXPR case, and we wonder if the only choice is between having new keywords and dropping the EXPR case.

Find expiring SSL certs using curl, Go and Perl.

Just like domain name registrations, SSL certificates need to be renewed regularly, otherwise they expire. This means you now have one more thing to monitor. Let's look at ways to do this in Perl, curl and Go. We'll also get a quick introduction to a hosted Mojolicious app that I wrote to make this even easier.

Read the full post.

Perl Weekly Challenge 244: Group Hero

These are some answers to the Week 244, Task 2, 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 November 26, 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 2: Group Hero

You are given an array of integers representing the strength.

Write a script to return the sum of the powers of all possible combinations; power is defined as the square of the largest number in a sequence, multiplied by the smallest.

Example 1

New Dancer, Dancer2 plus Ecosystem Updates

Welcome to 2023 (just a little bit late)! We've put together a number of long overdue updates for Dancer, Dancer2, and other parts of the ecosystem.

Dancer2 version 0.400001:

This week in PSC (096) | 2023-02-03

Just Paul and Philippe this week.

  • Smartmatch deprecation continues — just one more distribution left now (Test-Simple).
  • RFC process needs a new name and ID allocation scheme. We will continue discussing ideas and post when we have something presentable.
  • overload::v2 feels like the best solution to the problem of how to add substr overloading.
  • join overloading might want a join_uses_concat flag to avoid surprising existing modules.

United-domains supports the German Perl/Raku-Workshop

We are happy to announce that united-domains
supports the German Perl/Raku-Workshop!

united-domains ist ein erfahrenes Team von mehr als 80 Domain-Spezialisten, die sich zuverlässig und mit Leidenschaft um die Domains unserer Kunden kümmern. Wir inspirieren Brands und Professionals, ihre digitale Identität zu entwicklen.

Perl Weekly Challenge 244: Count Smaller

These are some answers to the Week 244, Task 1, 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 November 26, 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: Count Smaller

You are given an array of integers.

Write a script to calculate the number of integers smaller than the integer at each index.

Example 1

Annotated Test2::Tools Index

I have very gradually been adopting Test2::V0 as a testing tool. I had a test file that performed a group of tests inside a for loop, and discovered there were circumstances where I wanted to skip an iteration. Well, the skip() provided by Test2::Tools::Basic operates by executing last SKIP;. In the case of a labeled for this skips not only the current iteration but all subsequent iterations.

I wondered if there was a Test2::Tools plugin that did a next SKIP;, so I generated an annotated index of Test2 tools. This index reports all of them in ASCIIbetical order, with the distribution they are found in and the abstract from the =head1 NAME section of the POD.

Egad I have been a lazy Sod

Yep been a while since I posted something, been playing about with my HAM gear too much these days, but I do have a little gem of wisdom to share so here it is.

I updated my Mojolicious for the first time in quite awhile and my personal web server died.

Well this on was 100% my fault as the error was

Can't locate object method "route" via package "Mojolicious::Routes" at /johns/perl/Mojolicious-Plugin-Routes-Restful-0.03-2/blib/lib/Mojolicious/Plugin/Routes/Restful.pm line 124.

So I had a snoop around Mojolicious today and found this in the change log

8.67 2020-12-04
- Deprecated Mojolicious::Routes::Route::route in favor of Mojolicious::Routes::Route::any.
- Deprecated Mojolicious::Routes::Route::over in favor of Mojolicious::Routes::Route::requires.
- Deprecated Mojolicious::Routes::Route::via in favor of Mojolicious::Routes::Route::methods.

Color Evolution

The most requested feature of the Cellgraph is now in operation: Colors.
blau.png

I added one panel with all the options and functions to control them. It is a little complex, but well documented (see here). In short you can load and save from and to the config file single colors and color sets under special names. And then you have direct access to the gradient and the complimentary function of Graphics::Toolkit::Color. Reverting to the default grayscale is always possible with an push on a button.

Perl Weekly Challenge 243: Floor Sum

These are some answers to the Week 243, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a bit more than a day from now (on November 19, 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 2: Floor Sum

You are given an array of positive integers (>=1).

Write a script to return the sum of floor(nums[i] / nums[j]) where 0 <= i,j < nums.length. The floor() function returns the integer part of the division.

Example 1

PDF document creation with Markup languages

New, powerful features have recently been added to PDF::Builder and PDF::Table, enabling faster and easier high-level generation of PDF documents. The versions are respectively 3.025 and 1.005, and are available on CPAN.

This week in PSC (095) | 2023-01-27

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

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 Weekly Challenge 243: Reverse Pairs

These are some answers to the Week 243, Task 1, 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 November 19, 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: Reverse Pairs

You are given an array of integers.

Write a script to return the number of reverse pairs in the given array.

A reverse pair is a pair (i, j) where: a) 0 <= i < j < nums.length and b) nums[i] > 2 * nums[j].

Example 1

Input: @nums = (1, 3, 2, 3, 1)
Output: 2

(1, 4) => nums[1] = 3, nums[4] = 1, 3 > 2 * 1
(3, 4) => nums[3] = 3, nums[4] = 1, 3 > 2 * 1

Example 2

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.

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) | 2023-01-20

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.

About blogs.perl.org

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