This week in PSC (115) | 2023-09-07

This week, we discussed several topics:

  • collecting bugfixes to put in a 5.38.1 maintenance release
  • Module::CoreList automated releases, and how we might get them created — what PAUSE user, etc…
  • once the PPC for meta:: officially exists, it would be worth having a release on CPAN, to experiment with
  • the PPC process still needs some refinement and further clarification on what gets done, when, and by whom

TPRC Toronto Part 2

Well end of day two here and had a nice walk and a nice chat with one of the local city counselors who was out glad handing I asked her when the Gardiner Express Way will be fixed up. She said by Christmas ;)

That was a Local joke now onto what I got up to today.

Ovid despite Air Frances best efforts actually did make in to the conference late the night before so he was able to give his Keynote on OO in the Perl Core, Seems we will be getting something called Corinna Soon we will have Field, Class, Role and Method to play with and if you are brave you can get the latest version of perl and play with a few parts of it. The key sticky part is Typing, Seems there is another project out there called Oshum to handle all those nasty typing problems. Well to quote the main character Sweden's best know literature

'We shall see, what we shall see'

Perl Weekly Challenge 252: Special Numbers

These are some answers to the Week 252, 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 January 21, 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: Special Numbers

You are given an array of integers, @ints.

Write a script to find the sum of the squares of all special elements of the given array.

An element $int[i] of @ints is called special if i divides n, i.e. n % i == 0, where n is the length of the given array. Also the array is 1-indexed for the task.

Example 1

Support TPRF with Perl 5.38 swag purchases

800.jpg800a.jpg

Shirts and hoodies are available in variety of colours, sizes and styles. Stickers, mugs, and phone covers are also all available. With proceeds from sales funding The Perl and Raku Foundation.

Buy from https://the-perl-store.creator-spring.com/

This week in PSC (114) | 2023-08-31

This week, we talked about:

  • the recent quietness of the perl5-porters list
  • PPC 0013 and the use of a lexical feature (join_with_concat) to enable concat magic
  • inclusion of stringify (OP_STRINGIFY) and numify functions in the builtin namespace
  • turning the UNIVERSAL::import deprecation warning into a regular warning so as not to imply a removal timescale

Perl Weekly Challenge #224 - Passing Notes

Hi everybody! Just doing one challenge again this week. Time limitations hold me back once again.

This week we're looking for the letters of a target word in a source word, and we're not allowed to use the same letter twice. Spoiler alert because it's only Wednesday and you still have the rest of the week to submit solutions if desired.

The easiest way to do this is with a dictionary hash initialized like so:

foreach (split //, $source) {$chars{$_}++}

Many people use map() to do this, but I'm not a big fan of map in many cases because I feel it makes code less readable.

This gives us the number of occurrences of each letter in the original word.

Then we iterate through the target word and look for (and remove) the letters in the dictionary:

Perl Weekly Challenge 224: Special Notes

These are some answers to the Week 224, 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 July 9, 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: Special Notes

You are given two strings, $source and $target.

Write a script to find out if using the characters (only once) from source, a target string can be created.

Example 1

Input: $source = "abc"
       $target = "xyz"
Output: false

Example 2

Input: $source = "scriptinglanguage"
       $target = "perl"
Output: true

Example 3

Faster and up to date HTTP Cookie Jar

Hot off the keyboard, is HTTP::State in trial form anyway. This is HTTP cookie jar supporting public suffix, same site, cookie partitioning and other goodies from RFC6265bis-draft and CHIPS. It makes cookie handling on the client side more in line with recent developments in browsers (browsing context, first-party partitioning etc).

While most of 'browsing context' and partitioning features are not directly usable in current Perl HTTP user agents, it eases the path for better cookie support in new/updated user agents.

In the mean time, a compatibility API allows drop in usage where ever HTTP::CookieJar is used. The main benefit for current user agents is a significant boost in cookie retrieval performance.

It is a trial of a first release, so probably has some teething issues and is currently limited v5.36.0 min perl. However if you want to give it a try, please do and give feedback if you can!

This week in PSC (113) | 2023-08-24

The three of us met today, and we:

  • updated the status of stalled PPCs (after discussion with the proposers)
  • assigned a number (0023) to the map my $x { } PPC
  • discussed the evaluation order issue related to PPC 0021 (optional chaining)
  • decided that future rejected PPCs should have a section that details why they were rejected
  • discussed the tooling around the publication of dual-life modules on CPAN

SQL::Inserter for faster/multi-row inserting

SQL::Inserter is new CPAN module based on what we are using at SpareRoom to easily manage buffered inserts, as well as to replace SQL::Abstract's slow insert method.

Inserter OO interface

The idea is that if you want to insert many rows of data (e.g. part of an ETL pipeline, or writing logs etc), you'd want to be doing that with multi-row INSERT statements. With SQL::Inserter you create a very lightweight object to handle inserting for you, just pass it a DBI db handle, the table name and the columns you'll be inserting (optional if you use hashes for inserting, see next section):

Perl Weekly Challenge #223 - Count Primes? I've Never Met the Man

Hello everybody! It's another week with a new Perl Weekly Challenge. This week I'm only doing the first challenge, not because of time, but because the second challenge makes absolutely no sense to me. Perhaps a clarification will come out, but I'm not going to bother at the moment.

This week the challenge is to find the number of primes under the provided number. This is a challenge that really isn't worth rebuilding, and so I would recommend using Math::Prime::Util. You have to know when to just trust the professionals and use modules. With the use of M::P::U, we can essentially do the challenge in one line.

use Math::Prime::Util 'primes';
say scalar @{primes(shift)};

primes() returns an array reference, so we have to dereference the array after calling the function. We shift the number that is entered, call primes (which provides an array of the primes under that number), and dereference it and count it to print the answer.

It's that simple! This is a case where I definitely wouldn't recommend writing your own custom prime finder. I'll hopefully see you next week with the next challenge!

Perl Weekly Challenge 223: Count Primes

These are some answers to the Week 223, 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 July 2, 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 Primes

You are given a positive integer, $n.

Write a script to find the total count of primes less than or equal to the given integer.

Example 1

Input: $n = 10
Output: 4

Since there are 4 primes (2,3,5,7) less than or equal to 10.

Example 2

Input: $n = 1
Output: 0

Example 3

This week in PSC (112) | 2023-08-17

This week, for its first meeting, the new PSC:

  • discussed the nature of typing systems for Perl and what properties we find desirable vs not
  • worked out a release schedule for the next few months of devel releases
  • reviewed the PPC Tracker document. A few are now done, the rest need remainder nudge emails to their respective proposers

Cloud Provider Price Performance Comparison: Spot VMs

In my recent Cloud Comparison, I mentioned that I'd look at Spot VM pricing in an update. This is the update - 6 out of the 10 providers tested offer Spot/Preemptible instance pricing.

At SpareRoom we make some good use of Spot VMs. E.g. our perl test suite gets to run on fast VM types at very low cost: currently we are using c3-highcpu-22 instances which normally come at $0.95/hour each. The spot pricing for them is more than 10x lower, at just $0.086/h. At these prices, if our test suite needed it (it's already fast), we'd be able to launch c3-highcpu-176 (176 vCPUs) at well under $1/h!

Celebrate Perl 5.38 with Limited Edition merch!

2.png

To celebrate the upcoming release of Perl 5.38 we are excited to offer Limited Edition* merchandise.

The design was a true team effort by the marketing committee and is inspired by the traditional Perl camel logo. We had a lot of fun throwing around ideas, then throwing them in to AI to see what it's randomness would come back with. We then passed the ideas to our artist for the final result.

Check them out on the official Perl store where proceeds go to The Perl and Raku Foundation which then directly fund grants etc.

* TBD how limited.

Perl Weekly Challenge 251: Lucky Number

These are some answers to the Week 251, 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 January 14, 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 2: Lucky Number

You are given a m x n matrix of distinct numbers.

Write a script to return the lucky number, if there is one, or -1 if not.

A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.

Example 1

Perl Weekly Challenge #222 - Checking Against My List of Members

Hi everybody! Just doing the first weekly challenge task again this week. This week we're sorting a list of numbers and then checking whether the number matches the same position in the unsorted list. It's a very simple challenge and easily written in about 4 actual lines of clean code.

Here's the code:

#!/usr/bin/perl
use strict;
use v5.24;
my @sorted = sort @ARGV;
my $matches;
for (my $i = 0; $i <= $#ARGV; $i++) {$matches++ if $ARGV[$i] == $sorted[$i]}
say $matches // 0;

Profiling Perl under Apache

At SpareRoom we still use Apache/mod_perl and, despite Devel::NYTProf::Apache's warnings about it not being maintained, it is still the best way for profiling Perl.

All you need to do really, for a mod_perl app, is to include this in your Apache config:

PerlPassEnv NYTPROF # Not needed for default settings.
PerlModule Devel::NYTProf::Apache

You should also allow a single worker/child, and make sure it terminates cleanly before processing the output (nytprofhtml).

Since I want my dev/test environments to normally run with multiple workers and no profiler attached, I have a bash alias that exits apache and restarts it set-up for profiling. I thought I'd share an example of that, as I find it very useful.

First, a basic example pulled from what I used on our older CentOS/RedHat VM:

“Let Maintainers Be Maintainers”

Graydon Hoare:

[…] Corporate-employed FOSS maintainers working at a firm with these [very common] “growth and novelty” incentives [… are] in a position where their job performance is very likely to be evaluated in terms of visible growth and novelty (it might be dressed up in more abstract terms like “real-world impact” or “visibility” but it still means the same thing) even though that is exactly the wrong thing for the health of the project they’re maintaining.

I’m excerpting the gist of his article here but actually I suggest reading all of it. It’s not very long but gives flesh to this skeleton argument.

It doesn’t help that what he is talking about isn’t limited to employed maintainers; profit is not the only growth incentive structure that can lead to this novelty mindset, so this can exist entirely outside commercial context.

Perl Weekly Challenge 251: Concatenation Value

These are some answers to the Week 251, 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 January 14, 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: Concatenation Value

You are given an array of integers, @ints.

Write a script to find the concatenation value of the given array.

The concatenation of two numbers is the number formed by concatenating their numerals.

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.