Perl Weekly Challenge 278: Reverse Word

These are some answers to the Week 278, 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 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 2: Reverse Word

You are given a word, $word and a character, $char.

Write a script to replace the substring up to and including $char with its characters sorted alphabetically. If the $char doesn’t exist, then DON'T do anything.

Example 1

Input: $str = "challenge", $char = "e"
Ouput: "acehllnge"

Example 2

Input: $str = "programming", $char = "a"
Ouput: "agoprrmming"

Example 3

Today I learned... #1: variable scoping in if-else blocks

This block of code is valid Perl:

if (my $var1 = calc1()) {
    say $var1;
} elsif (my $var2 = calc2()) {
    say "$var1, $var2";
}

As you can see, $var1, which is declared in the if clause, is visible inside the elsif clause too.

Perl never ceases to amaze me!

(Also appears in my blog)

Parallel Perl/C applications without tears using OpenMP: Controlling the OpenMP environment

Brett Estrade, did it again with yet another excellent talk at TPRC 2024 about the use of OpenMP for parallelizing Perl/C code. This is an area that is extremely interesting as OpenMP is a rather straightforward way to parallelize code using simple compiler pragmas in Inline::C sections of code. Furthermore, as I discussed at TPRC2024, the combination of the Many Core Engine (MCE) and OpenMP allow the Perl user to endow a specific piece of code with both process and thread level parallelism, bleeding the hardware for performance without losing the benefits of Perl for high level coding.

Since this an area that may not be familiar to many users, I decided to start blogging about Perl/C parallel application programming at Killing It With Perl . The first post in this series is about a rudimentary control of the OpenMP environment , e.g. setting up the number and scheduling of the threads and you can read all about it here.

This week in PSC (151) | 2024-06-13

Graham and Philippe met briefly today.

Now that Perl 5.40 is out, and the nomination process for the next PSC is underway, there wasn’t much to discuss, so we cut the meeting short.

Perl Weekly Challenge 278: Sort String

These are some answers to the Week 278, 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 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: Sort String

You are given a shuffle string, $str.

Write a script to return the sorted string.

A string is shuffled by appending word position to each word.

Example 1

Input: $str = "and2 Raku3 cousins5 Perl1 are4"
Output: "Perl and Raku are cousins"

Example 2

Input: $str = "guest6 Python1 most4 the3 popular5 is2 language7"
Output: "Python is the most popular guest language"

Example 3

Input: $str = "Challenge3 The1 Weekly2"
Output: "The Weekly Challenge"

MariaDB 10 and SQL::Translator::Producer

Following up on my previous post (MariaDB 10 and Perl DBIx::Class::Schema::Loader), I wanted to try the 'deploy' feature to create database tables from Schema/Result classes.

I was surprised that I could not create a table in the database when a timestamp field had a default of current_time(). The problem was that the generated CREATE TABLE entry placed quotes around 'current_timestamp()' causing an error and rejected entry.

As mentioned in a previous post, I had created file SQL/Translator/Producer/MariDB.pm as part of the effort to get MariaDB 10 clients to work correctly with DBIx::Class::Schema::Loader. Initially it was a clone of the MySQL.pm file with name substitutions. To correct the current_timestamp problem I added a search/replace in the existing create_field subroutine in the MariaDB.pm file to remove the quotes.

Confirming The LPW 2024 Venue & Date

We're happy to confirm the venue and date of this year's London Perl & Raku Workshop.

When: Saturday 26th October 2024
Where: The Trampery, 239 Old Street, London EC1V 9EY

This year's workshop will be held at The Trampery, at Old Street. A dedicated modern event space in central London. We have hired both The Ballroom and The Library; allowing us to run a main track for up to 160 attendees, and second smaller track for up to 35 attendees.

The Trampery in Old Street is located a two minute walk from the Northern Line's Old Street tube station in central London. The Northern Line has stops at most of the major train stations in London, or trivial links to others, so we recommend taking the tube to get to the venue.

If you haven't already, please signup and submit talks using the official workshop site: https://act.yapc.eu/lpw2024/

Thanks to this year's sponsors, without whom LPW would not happen:

If you would like to sponsor LPW then please have a look at the options here: https://act.yapc.eu/lpw2024/sponsoring.html

Making a Super Cal if Rage Will Stick Ex Paella Down Us

Something I am not good at

The paella must be possibly the worst national dish ever created, I thought to myself as I looked at the charred remains in my pan. It is as if the mind of some ancient Spanish conquistador, returned from his conquests abroad feeling hungry and unfulfilled, dreamt of bringing byriani to Spain, but in the midst of pillaging had forgotten to take culinary notes.

"How difficult can it be, Jose?" the weary warrior muses,
"Yeah, yeah, its just rice and meat, innit", says his Catalan colleague coming from the Spanish equivalent of Birmingham.
"We could use something flavourless, amorphous and chewy, like mussels, instead of meat",
"Whoaaah, nice,",
"And langoustines...",
"langa-what?",
"I know, right? Just throw them all in, don't bother shelling them",
"Raphael has some tomatoes he doesn't need for pelting passing pedestrians",
"Ahh...the flavours", fanning the flames as the smell of their concoction cooking brings back fond memories of far-away burning villages.

Perl Weekly Challenge 277: Strong Pair

These are some answers to the Week 277, 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 14, 2024, known in France as Bastille Day, 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: Strong Pair

You are given an array of integers, @ints.

Write a script to return the count of all strong pairs in the given array.

A pair of integers x and y is called strong pair if it satisfies: 0 < |x - y| < min(x, y).

Example 1

Input: @ints = (1, 2, 3, 4, 5)
Ouput: 4

Strong Pairs: (2, 3), (3, 4), (3, 5), (4, 5)

Example 2

This Week in PSC (147)

Just Graham and Paul

  • Reviewed the release-blockers label. Only two left, one is a documentation fix (PR22055)
  • Reviewed another documentation PR that should go in for 5.40 (PR22200)

Aside from that, things are looking good for making a 5.40 release at the usual schedule in May.

MariaDB 10 and Perl DBIx::Class::Schema::Loader

Fixing DBIx::Class::Schema::Loader For Use With MariaDB 10 Client Software

I recently set up a virtual Server Running Rocky Linux 9 as a client from which to query a remote MariaDB database. I used perlbrew to install Perl 5.38.2. I installed client related RPMs for MariaDB 10.5, I installed DBIx::Class as a relational mapper that can create Perl Schema Result Classes for each table in the database. If you are new to DBIx::Class, you can review its purpose and features in DBIx::Class::Manual::Intro. The Result Classes used by Perl to query the database are stored on the client server in a schema directory. They are created with the DBIx::Class::Schema::Loader module.

Perl Toolchain Summit 2024 - Lisbon

This year I was invited to the PTS conference in Lisbon as part of the CPAN Security group. Together we have been working on ways to improve the security of the Perl ecosystem. This was a great chance for members of the CPANSec group to meet in person, get to know each other better and discuss some of the items we have been working on lately. Welcome to Nicolas our newest member.

Perl Weekly Challenge 277: Count Common

These are some answers to the Week 277, 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 14, 2024, known in France as Bastille Day, 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 Common

You are given two arrays of strings, @words1 and @words2.

Write a script to return the count of words that appears in both arrays exactly once.

Example 1

Input: @words1 = ("Perl", "is", "my", "friend")
       @words2 = ("Perl", "and", "Raku", "are", "friend")
Output: 2

The words "Perl" and "friend" appear once in each array.

Example 2

Carp::Object, an object-oriented replacement for Carp and Carp::Clan

The new Carp::Object module is an object-oriented replacement for Carp or Carp::Clan. What is the point ? Well, here is some motivation.

The Carp module and its croak function have been around since perl 5.000. Errors can then be reported from the perspective of where the module was called, instead of the line where the error is raised. This excellent example from Mastering Perl explains why this is useful :

1	package Local::Math {
2	  use Carp qw(croak);
3	  sub divide {
4	    my( $class, $numerator, $denominator ) = @_;
5	    croak q(Can't divide by zero!) if $denominator == 0;
6	    $numerator / $denominator;
7	  }
8	}

The Perl Toolchain Summit 2024

Sometimes life catches up with you. I've felt that way for the last few years and I'm probably not alone.

During that time the cpancover project has basically just been plodding along, pretty much just working. As new modules were uploaded to CPAN, cpancover would pick them up, calculate the test coverage, and make the results available to be displayed on metacpan, along with detailed output on cpancover.com.

A little while ago I decided it was probably about time that I should update the OS and perl version and libraries and stuff.

And it went terribly.

Benchmark::DKbench Perl benchmark suite now supports custom benchmarks.

Tried posting this on Reddit instead, but there seem to be some issues with code insert there, so here it is properly:
Although Benchmark::DKbench is a good overall indicator for generic CPU performance for comparing different systems (especially when it comes to Perl software), the best benchmark is always your own code. Hence, the module now lets you incorporate your own custom benchmarks. You can either have them run together with the default benchmarks, or run only your own set, just taking advantage of the framework (reports, multi-threading, monotonic precision timing, configurable repeats with averages/stdev, calculation of thread scaling etc). Here's an example where I run a couple of custom benchmarks on their own with Benchmark::DKbench:

Perl Weekly Challenge 276: Maximum Frequency

These are some answers to the Week 276, 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 7, 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: Maximum Frequency

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

Write a script to return the total number of elements in the given array which have the highest frequency.

Example 1

Input: @ints = (1, 2, 2, 4, 1, 5)
Ouput: 4

The maximum frequency is 2.
The elements 1 and 2 has the maximum frequency.

Example 2

This week in PSC (150) | 2024-06-06

The three of us were there, and our discussion covered:

  • 5.40.0 has no more blocking bugs 🎉
  • It should be released by the end of the week
  • PPC0021 progress continues with Paul and Veesh discussing debugging and development
  • The maintainer of HTTP::Tiny delegates design decisions to the PSC. There’s one PR outstanding that we looked over and found agreeable

Perl Toolchain Summit 2024 - Lisbon Portugal

I just got back from the Perl Toolchain Summit 2024 in Lisbon Portugal!

Thank you to Grant Street Group for sponsoring my attendance at the event! Grant Street Group is an amazing place to work, and GSG is hiring! Contact me on irc.perl.org (Exodist) if you would like a referral.

This year I took a little side trip before the PTS to explore Lisbon with my wife. It is an amazing city, with a lot of history. I highly recommend visiting it and exploring the castles, palaces, and archaeological sights!

My goal for the PTS was to polish up Yath 2.0 and get it out the door. Spoiler alert: I did not achieve this goal, though I did make good progress. Instead several other things occurred that were even better as far as achieving things that require collaboration go!

Test2/Test2::Suite updates

LPW 2024 - Call For Papers and Sponsors

The London Perl & Raku Workshop (LPW) will take place this year on Saturday 26th October and you are encouraged to submit your talk proposals now. We have already had 30 registrations for the workshop so we anticipate a good turnout this year.

We welcome proposals relating to Perl 5, Raku, other languages, and supporting technologies. We may even have space for a couple of talks entirely tangential as we are close to finalising the venue (very central London) and should have room for two tracks.

Talks may be long (40mins), short (20 mins), or very short (aka lightning, 5 mins) but we would prefer talks to be on the shorter side and will likely prioritise 20min talks. We would also be pleased to accept proposals for tutorials and discussions. The deadline for submissions is 30th September.

We would really like to have more first time speakers. If you’d like help with a talk proposal, and/or the talk itself, let us know - we’ve got people happy to be your talk buddy!

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.