Chapter 3 of Higher Order Perl describes various approaches to memoization of an expensive function: private cache and the Memoize module. The book was written in 2005 (Perl was at version 5.8 back then) , so it does not include another way for function caching that is now available : caching through state variables (introduced in Perl 5.10). The Fibonacci example considered in HOP also requires the ability to initialize state hash variables (available since Perl 5.28). The code below contrasts the implementation with a state variable v.s. the memoize module:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on August 11, 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: Knight’s Move
A Knight in chess can move from its current position to any square two rows or columns plus one column or row away. So in the diagram below, if it starts a S, it can move to any of the squares marked E.
Write a script which takes a starting position and an ending position and calculates the least number of moves required.
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.
Discussed tracking perl authorized releasers updates and storing historical data
Dual-Life modules need some cleanup to get a more normal release process that can be done more regularly. Cleanup has been done on Storable.
Time::HiRes by default doesn’t seem terrible, if possible
X509 in core could make sense as part of a more complete interface to OpenSSL
Discussion about how it would be possible to have support for Markdown or other new Pod extensions in a more backwards compatible way. Possibly a way to define alternate formats for =begin/=end sections.
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:
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on May 19, 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: Distribute Elements
You are given an array of distinct integers, @ints.
Write a script to distribute the elements as described below:
1) Put the 1st element of the given array to a new array @arr1.2) Put the 2nd element of the given array to a new array @arr2.
Once you have one element in each arrays, @arr1 and @arr2, then follow the rule below:
If the last element of the array @arr1 is greater than the last
element of the array @arr2 then add the first element of the
given array to @arr1 otherwise to the array @arr2.
When done distribution, return the concatenated arrays. @arr1 and @arr2.
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.
We merged HTTP-Tiny#6, and then discussed a number of topics:
some improvements on the process for releasing blead-upstream dual-life modules are needed
the instructions for releasing a new Perl are difficult to follow and partly redundant, the process takes longer than it should, and more of it could be automated
the pumpkin permission list has grown over time, and probably needs to be trimmed
more talk about Markdown documentation
thoughts on how to strike a better balance with the verbosity/brevity of meeting minutes
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.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on May 12, 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: Number Game
You are given an array of integers, @ints, with even number of elements.
Write a script to create a new array made up of elements of the given array. Pick the two smallest integers and add it to new array in decreasing order i.e. high to low. Keep doing until the given array is empty.
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.
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.
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 }
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.
This week it was just Paul and Philippe; we discussed the final changes
for the upcoming RC2 and stable release, and marked some issues/PR as
release blockers.
Graham expects to release 5.40-RC2 before the week-end.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on August 11, 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: Check Color
You are given coordinates, a string that represents the coordinates of a square of the chessboard as shown below:
Write a script to return true if the square is light, and false if the square is dark.
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:
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!