This Week in PSC (138)

Back to the usual three of us

  • Further chats on allowing a subsequent use VERSION of the same value as is already prevailing

  • We continued going through the bug list to tag release blockers

Perl Weekly Challenge 258: Count Even Digits Numbers

These are some answers to the Week 258, 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 March 3, 2024 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: Count Even Digits Number

You are given a array of positive integers, @ints.

Write a script to find out how many integers have even number of digits.

Example 1

Input: @ints = (10, 1, 111, 24, 1000)
Output: 3

There are 3 integers having even digits i.e. 10, 24 and 1000.

Example 2

Input: @ints = (111, 1, 11111)
Output: 0

Example 3

Dodging the Go loop trap

Ted Unangst:

And now we’re trapped. There’s only one friend variable, constantly changing as we go through the loop, with the most likely result one of our friends will get half a dozen messages, while the other five receive nothing, to the annoyance of both groups.

Funny that Perl got this one right when not only many before didn’t but many since also haven’t.

In Go, as Ted says, they may even change the language to fix it; in Javascript, they already have.

Setting up a free Oracle Database for Perl development

I recently added Oracle Database support to SQL::Inserter (check it out if you'd like simple to use, high-performance inserting to SQL databases). I had not used an Oracle Database since my uni days 20 years ago, so I had to set one up to test it.

Even though Oracle provides a free development DB, the process is not as simple as Postgres/MySQL etc., so I thought I'd document it for future reference.

There are basically two ways you can go, with Oracle providing instructions either for a VirtualBox VM, or Docker. For the purposes of this article, we'll use VirtualBox. If you prefer Docker, you can follow Oracle's instructions and skip the next section.

Setting up the Oracle VM

Oracle provides instructions for setting up a VM with their latest 23c Database.

To sum up, you download and install VirtualBox, as well as the 23c VM image (.ova).

Launch VirtualBox, go to File->Import Appliance and select the .ova file that you just downloaded. You can leave the defaults for the import.

This Week in PSC (137) | 2024-02-22

Paul was away this week.

  • we talked about the hiccups that PAUSE seems to have been through
  • we discussed further changes to the use VERSION behaviour (warnings)
  • and we started going through the bug list to tag release blockers

Dancer Advent Calendar 2023

Hey Dancers! We’re doing an advent calendar this year, and we’d love for you to contribute. Tell us your Dancer success story! Write about a project you worked on that used Dancer, a plugin you wrote, a plugin you love, anything.

December is coming fast, so get your ideas in now. Please reply to this post if you’d be interesting in helping with this year’s advent calendar.

2024 Perl Conference - Science Track Interest Survey

Greetings Perl People!

There is a strong official consideration by The Perl and Raku Foundation of including a new kind of track to the 2024 Perl and Raku Conference in Las Vegas.

Survey URL: https://forms.gle/DDPWsNqEsZW8AyWX7

The track would target academic and industrial STEM applications, and emulate in some way traditional science conference tracks; meaning the talks would be based on paper and poster submissions. If this came to pass, the Science Perl Committee would also follow up with the publishing of the papers in an official proceedings of this track. But we need your feedback!

Survey URL: https://forms.gle/DDPWsNqEsZW8AyWX7

Please complete and share the survey link so that we may convince the already overworked TPRC planning committee that it's worth the extra effort :-). You may also express support in the comments section below or email them directly to me so that I may forward them to the TPRF - oodler@cpan.org. There are ongoing discussions in the TPRF Slack also - see you there! A call for volunteers will be made at such a time that this proposal is accepted.

Sincerely,
Brett Estrade
oodler@cpan.org
Chairman, Science Perl Committee

Recordings of the German Perl Workshop (gpw2023) are online

After a long time of work, the videos are finally available on Youtube. 20 presentations with a total of 14 hours of airtime review the three days of the workshop and you can watch the things you missed on site.

We would especially like to thank Lee Johnson, who made the recordings, and the presenters, of course, without whom the workshop would not have taken place. The support from our sponsors helps us make the workshop take place.

OTOBO
united-domains
Perl-Services.de Renée Bäcker
Geizhals Preisvergleich
PayProp

The recordings of the German Perl Workshop 2023 are organised in the order of the day in a playlist available at gpw2023.

We are planning the German Perl Workshop 2024 again and are already in the final negotiations. As soon as we have a place and date fixed, we will update this post and also make a separate announcement.

PSC #136 2024-02-15

  • working out a timeline of what should go in to 5.39.8, 5.39.9, and what to defer to 5.41
  • draft tests+docs received from Martijn Lievaart (“M4”) for a logical xor (^^) operator
  • the responses saying no to adding Data::Printer in core that it doesn’t seem like it would be popular
  • some potential new sprintf format templates:
    • a float template that produces the shortest string that represents the exact float (similar to what Math::Ryu does),
    • a %q to access B::perlstring/quotemeta or something similar
  • the realisation that, some months ago, Mark Gardner had volunteered to work on the SSL-in-core project, and we haven’t heard from them since.

Config::Tiny V 2.30 supports keys with arrays as values

Yes, it's true. Config::Tiny now allows you to assign an array of values to a key.
The docs have been updated to include a new section, ARRAY SYNTAX.
Various examples are documented there and in test files. Sample usage:

[section]
greetings[]=Hello
greetings[]=World!
one=two
Foo=Bar

Note: The 2 lines of greetings can be separated by other lines too.

You access these values like this:
say $Config->{section}->{greetings}->[0];
say $Config->{section}->{greetings}->[1]

This patch was kindly provided by Steven Schoch.

See the Changes file for details.

Perl Weekly Challenge 238: Persistence Sort

These are some answers to the Week 238, 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 October 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.

Task 2: Persistence Sort

You are given an array of positive integers.

Write a script to sort the given array in increasing order with respect to the count of steps required to obtain a single-digit number by multiplying its digits recursively for each array element. If any two numbers have the same count of steps, then print the smaller number first.

Example 1

Announcing Dancer2 1.0.0

On behalf of the Dancer Core Team, I am beyond excited to present you with Dancer2 1.0.0.

So how did we get here? Why now? I'll cover the specifics in a future blog post, but suffice it to say for now, we're stable, and we've been stable for a long time, but this was never reflected in our versioning. It's beyond time to commemorate that milestone.

If you're expecting big changes, you'll be disappointed that there aren't many on the technical side. Much of what's in this release involves adding some polish in spots, and smoothing out some jagged edges in others. Some important highlights include:

This Week in PSC (135) | 2024-02-08

This week, the three of us:

  • noted that use VERSION restrictions have had mostly positive responses
  • thought that Data::Printer can’t go in core as-is, but there’s a use case for a debugging helper, some of which might be hidden in D:P’s core
  • discussed adding a builtin::numify function (and the corresponding OP in core)
  • quickly reviewed the PPCs currently being implemented:
    • we should ping the implementors of PPC0014 (English names) and PPC0021 (optional chaining)
    • PPC0022 (meta) has an implementation on CPAN
    • PPC0019 (qt strings) implementation is in progress, but unlikely to be done by 5.40
    • PPC0013 (overload in join) is currently stalled

Perl Weekly Challenge #237 - Carpe Diem

Hello everybody! Welcome back to the Weekly Challenge series, where today we're working on dates again. I like these challenges in particular, for some reason. In this case, we have a rather simple challenge except that it gives us less common date formats than usual.

The challenge gives us a year, month, week(day) of the month, and day of week. Now DateTime provides us with get operations to find WoM and DoW info, but it doesn't provide set operations. For that we need to do a little math. Here's the code below:

plenv-libdirs

A plenv plugin to add additional include directories to Perl.

This plugin sets the contents of file .perl-libdirs. It hooks into plenv-exec command and every time you run perl or any other command under plenv, plenv-libdirs uses the .perl-libdirs files to set the PERL5LIB environment variable.

plenv-libdirs makes use of .perl-libdirs files in the current working directory and every directory between it and root. Environment variable PERL5LIB has a list of paths separated (like in PATH) by a colon on Unixish platforms and by a semicolon on Windows (the proper path separator being given by the command perl -V:path_sep). When plenv-libdirs collects the paths from .perl-libdirs files, the order of the paths follows the order of the directories. The longer the path to .perl-libdirs file, the higher precedence in PERL5LIB.

Perl Weekly Challenge 236: Exact Change

These are some answers to the Week 236, 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 October 1, 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: Exact Change

You are asked to sell juice each costs $5. You are given an array of bills. You can only sell ONE juice to each customer but make sure you return exact change back. You only have $5, $10 and $20 notes. You do not have any change in hand at first.

Write a script to find out if it is possible to sell to each customer with correct change.

Example 1

This Week in PSC (134) | 2024-01-25

All three of us returned.

We only had one issue to discuss, the pressing matter of how to handle lexical unimports, builtin version bundles, the integration with use VERSION, and various related topics.

It’s complicated. We’ve been putting together a longer mail on the subject and that will come out as its own thread soon.

Hash of Arrays Deathmatch : Native Perl vs. DBM::Deep vs. Redis

Sometimes one has to make compromises between speed of execution and memory, other times one may not have to be. While working towards a fairly (at least in my mind) complete solution to map Nanopore Sequencing files, I ran against the need to create and access fairly large hash of arrays (think of 1M - 100Mof keys), with each array itself consisting of a a fixed number of elements.
The hash of arrays is a fairly straightforward and fast data structure to create in Perl, the memory overhead can be substantial as the number of keys and values scale upwards. While in my application (at least as envisioned now!) the hash will be created, aggregated over (group by for those into python-pandas or r-data.table vernacular) and then discarded, there are use cases in which the data should be preserved to avoid the computational expensive part of generating them via approximate string matching in biological databases.

Writing Perl with Emacs: Are there perl-mode users around?

Emacs comes with two different major modes to edit Perl code: perl-mode and cperl-mode.

perl-mode is somewhat stuck with the Perl syntax of 5.14, has less features, but a cleaner implementation. cperl-mode is up to date with Perl 5.38 and has deeper understanding of Perl syntax, but a somewhat arcane implementation, most of it written in the previous century.

With all due respect to TIMTOWTDI, maintaining two major modes turns out to be not enough fun in the long run, and last week Stefan Kangas opened a wishlist item to Making perl-mode.el obsolete.

The mail thread shows that some people prefer perl-mode because it is less "colorful" and intrusive than cperl-mode. Therefore, the idea is to enable cperl-mode to (optionally) look like and behave like perl-mode. That way, perl-mode.el can be obsoleted without making those users uncomfortable: perl-mode would continue to exist as a custom theme of cperl-mode.

Perl Weekly Challenge 257: Reduced Row Echelon

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

Warning: I wrote the program below and this blog post from an hospital bed in a heart intensive care unit. I think my mind is clear, but there may very well be a better way to solve the task. Also, I do not have the energy to port this Raku program to other languages, nor to provide lengthy explanations.

Task 2: Reduced Row Echelon

Given a matrix M, check whether the matrix is in reduced row echelon form.

A matrix must have the following properties to be in reduced row echelon form:

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.