This week in PSC (086) | 2022-11-11

We're trying out new ways to send out these regular announcements of what we get up to on the Perl Steering Council. This will be a regular posting that gives a brief summary of what we discussed in our weekly (or at least, near-weekly, give or take scheduling clashes) meetings.

  • Internals docs (such as perlguts, perlapi) could be done better, but it's unclear how. Some new documents might be useful, but there's a risk of spending too much time on obscure internal specifics that almost nobody will ever need to read about or touch.
  • Smartmatch deprecation continues. Philippe has sent patches to CPAN modules that may be affected. autodie still needs some further work.
  • (As alluded to by this very blog post) we discussed communication strategies for user-facing news announcements. Thoughts are to post here on blogs.perl.org and send links elsewhere - such as Twitter, Reddit, etc.. We don't have a good feel for where folks will find it, so we'll just have to adapt as we go.
  • The module_true branch which implements the RFC is now merged and will be default in use v5.38. This will mean you no longer need to remember that final 1; line at the end of your module file.

Perl Weekly Challenge 228: Empty Array

These are some answers to the Week 228, 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 August 6, 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: Empty Array

You are given an array of integers in which all elements are unique.

Write a script to perform the following operations until the array is empty and return the total count of operations.

If the first element is the smallest then remove it otherwise move it to the end.

Example 1

Array Degree

The Weekly Challenge 189/2

The Task 2 was rather interesting in the week 189.

You are given an array of 2 or more non-negative integers.

Write a script to find out the smallest slice, i.e. contiguous subarray of the original array, having the degree of the given array.

The degree of an array is the maximum frequency of an element in the array.

Spoken like a 1980s chip

In the beginning

TWC 189: Saving your Degree by Great Character!

In which we achieve Single Pass and Single Expression, respectively.

Next door to the Haunted Mansion.

Perl Weekly Challenge 228: Unique Sum

These are some answers to the Week 228, 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 August 6, 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: Unique Sum

You are given an array of integers.

Write a script to find out the sum of unique elements in the given array.

Example 1

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

In the given array we have 2 unique elements (1, 3).

Example 2

The scoop on Windows running Perl

Scoop is a command-line installer for Windows that allows you to install a local user copy of Perl and other open source programming languages.

To get started, just install scoop on your windows machine by typing this in a powershell terminal:


irm get.scoop.sh | iex

If this doesn't work you might have to set a Powershell execution policy by typing this in your Powershell terminal :

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Check the Readme docs for more information on how it all works. After scoop is installed you can install perl by just typing :

scoop install perl

Here is a screenshot on how it worked for me:

scoop_install_perl.png

You can also install Rakudo Star bundle by typing :

scoop install rakudo-star

what will you scoop install on your Windows machine?


Next stable DBD::SQLite will be released at the beginning of November

DBD::SQLite 1.71_07 (with SQLite 3.39.4) is a release candidate for the next stable DBD::SQLite. This release is mainly to address a security hole found in SQLite, plus a few performance issues for perl built with -DDEBUGGING. See Changes for other fixes and changes.

This time I'll wait for about a week and release 1.72 at the beginning of November if there's no blocker nor request to wait for more. Thank you for your patience.

Buy a Perl 5.36 mug and support The Perl Foundation

Mugs celebrating Perl 5.36 are now available at The Perl Store with all proceeds going to The Perl Foundation

p536mug.jpg

Perl Weekly Challenge 227: Roman Maths

These are some answers to the Week 227, 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 July 30, 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: Roman Maths

Write a script to handle a 2-term arithmetic operation expressed in Roman numeral.

Example

Class::Plain supports Role using Role::Tiny


Class::Plain was released at at 2022-09. This time, Class::Plain supports role using Role::Tiny at version 0.05.

Frankfurter Perl Workshop 2022 - 6.11.2022

Hello everybody,

we hold the Frankfurter Perl Workshop on the 06. November 2022 in Frankfurt am Main. This is mostly a German-language event, so I'll just repost the German announcement:

Hallo zusammen,

am Sonntag, dem 06. November 2022 veranstalten wir wieder den Frankfurter Perl Workshop. Der Workshop findet wie 2019 im Haus der Jugend statt.

Mystery Buglet #2

Hey! I know, I know: long time, no blog.  I would love to blame the pandemic, but the truth is, I just haven’t been inspired with any sufficiently Perl-y topics lately.  Until recently, when I ran into this.

Now, once upon a time, I wrote a post about a small buglet I had encountered.  The post presented the problem, then asked you if you saw the problem, then explained what was going on.  So let’s do that again.  First, the code:
sub generate_temp_file
{
state $TMPFILES = [];
END { unlink @$TMPFILES }
my $tmpfile = `script-which-generates-tempfile`;
chomp $tmpfile;
push @$TMPFILES, $tmpfile;
return $tmpfile;
}

As before, the actual code does a bit more, but I promise I’ve omitted nothing that’s relevant to the bug.  Do you see it?  If not, click to find out more.

Perl Weekly Challenge 227: Friday 13th

These are some answers to the Week 227, 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 30, 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: Friday 13th

You are given a year number in the range 1753 to 9999.

Write a script to find out how many dates in the year are Friday 13th, assume that the current Gregorian calendar applies.

Example

Input: $year = 2023
Output: 2

Since there are only 2 Friday 13th in the given year 2023 i.e. 13th Jan and 13th Oct.

The deep, the shallow and the ugly (classes)

Previously I showed parts of the API of my new module Graphics::Toolkit::Color. This time I want to mention some bits about the code base, which demonstrate what I tried to say long ago (sorry for the long delay i hope I can complete the series).

Meet jp

Welcome

Please welcome the latest JSON tool for the command line: jp!

jp (mostly named from the Mojolicious class Mojo::JSON::Pointer that makes jp possible) is a command line tool for quickly extracting data from a JSON object.  How many times do we get a complex JSON object from some command and we just need to extract a specific set of values from it?  Every time!  All the time!  Often, people use basic tools like grep and sed.  Most people reach for jq, but I find the syntax too cumbersome to use just to extract my desired data.  I just want to use JSON Pointers and move on, but, indeed, sometimes JSON Pointers aren't even enough.  jp really shines with some helpful command line arguments, a regular expression JSON Pointer syntax, and, finally, a Perl eval argument for total power.

Get on with it

Let's see jp work.  Each example explainer links to the JSON Object used for the example.

Here's the most basic use.

$ jp /server/0/password < t/json1.json

REDACTED_APIKEYfalse

Sending a simple email

To have a secure SMTP delivery, use Email::Sender. Mail::Sendmail uses SMTP for transport and there's no other type of transport. It does not support SMTP authentication, which my SMTP server now requires even for access from localhost. From what I read and tried once or twice in the past, the current "best practice" or recommended way is to use Email::Sender. Here's an incantation to send mail using sendmail:

use Email::Sender::Simple qw(sendmail);
use Email::Simple;
use Email::Sender::Transport::Sendmail qw();
use Try::Tiny;my $email = Email::Simple->create(
header=>[To=>$to, From=>$from,
Subject=>$subject],
body=>$body,
);try {
sendmail($email,
{from=>$from,
transport=>Email::Sender::Transport::Sendmail->new});
} catch {
print "Can't send mail: $_";
}
  • It's easy to switch transport to SMTP (just change two lines).

  • It's easy to add SMTP authentication (just pass arguments to transport constructor).

  • It's easy and clear where to add custom email headers (whereas in Mail::Sendmail, some arguments are "magical"/processed, they do not correspond 1:1 to headers).

  • It's easy to construct multipart email (construct the appropriate $email object).

In addition:

  • Envelope sender and RFC822 From is clearly separated, forcing beginners to understand the concept.

So there you have it, sending an temp email in Perl the modern way. No longer apt for one-liners though.

Perl Weekly Challenge 226: Zero Array

These are some answers to the Week 226, 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 July 23, 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: Zero Array

You are given an array of non-negative integers, @ints.

Write a script to return the minimum number of operations to make every element equal zero.

In each operation, you are required to pick a positive number less than or equal to the smallest element in the array, then subtract that from each positive element in the array.

Example 1:

Look mom I invented colors

Just released Graphics::Toolkit::Color for the purpose to create computationally harmonic color pallets (2-3 lines max for most needs). It is in fact a chunk out of Chart I needed to reuse in other projects as the Harmonograph. And as you can see in the SEE ALSO section of the POD - I'm aware that there are plenty other modules doing, parts, similar stuff or even more.

TPF launches merch store for Perl 5

TPF has launched an online store with Perl merchandise (swag) celebrating the Perl 5.36 release. The marketing committee plan to do a custom celebratory collection for each release of Perl with revenue from each sale goes to TPF's Perl fund.

The store includes long- and short-sleeved t-shirts, sweatshirts, hoodies and stickers - all featuring a new Raptor image for the 5.36 release.

800.jpga800.jpg

From: https://news.perlfoundation.org/post/tpf-merch-store

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.