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

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

Of Go, C, Perl and fastq file conversion Vol II : the Jedi regex

In the second part of this series about fast parsers for sequencing applications,  I will review the code for the regex based parser. This is shown below (I use v5.38, as you should! because the year is 2023 and you should not have to type use strict; use warnings)

Resource::Silo - declarative lazy resource container library

Resource::Silo is a declarative lazy resource container library for Perl. It allows to declare resources such as configuration files, database connections, external service endpoints, and so on, in one place; acquire them on demand; cache them; and release in due order.

It may also be described as the single source of truth for the application's side effects.

For those unfamiliar with Bread::Board:

Hey, hey, hey, hey! A shiny new solution just arrived!

  • declare all of your application's resources / dependencies in one place using a simple DSL;
  • instantiate them on demand and only once, with little overhead;
  • override them with mocks in your tests & guard against unexpected side effects;
  • gain more fine-grained control via the ctl frontend.

For Bread::Board users:

Perl Weekly Challenge 238: Running Sum

These are some answers to the Week 238, 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 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 1: Running Sum

You are given an array of integers.

Write a script to return the running sum of the given array. The running sum can be calculated as sum[i] = num[0] + num[1] + …. + num[i].

Example 1

Input: @int = (1, 2, 3, 4, 5)
Output: (1, 3, 6, 10, 15)

Example 2

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

Example 3

This week in PSC (111) | 2023-08-11

Today was PSC 111 — what happened to 110 you ask? Well, it was a bit of a non-meeting a few weeks ago. Nothing to say about it, sorry!

This week, we:

  • Said hello to Graham and goodbye to Rik
  • We did a bunch of handover, making sure we set up a new Zoom meeting and calendar, and talking about our usual order of business

In more normal business, we:

  • talked about the future of use vX, especially related to builtin:: stuff — do we want “use v5.40” to import “builtin::refaddr” for example
  • talked about what we’re going to do with the UNIVERSAL::import changes so we can move it forward toward someday making it fatal but without breaking half of CPAN at once

Foswiki-2.1.8 has been released

Dear all,

we've got a new release out. Update is highly recommended as it fixes 9 critical security related bugs, i.e.

  • CVE-202: 3-33756: SpreadSheetPlugin's EVAL feature exposes information about paths and files on the server
  • CVE-2023-24698: Local file inclusion vulnerability in viewfile

Read more about it at https://blog.foswiki.org/Blog/Foswiki218IsReleased

Regards,
Michael.

No One Is Immune to Abuse

Once again I'm writing about a TPRC talk instead of a weekly challenge project, but that's because I feel it's a very important topic to be aware of both inside and outside our community as Perl programmers. Sawyer X gave a really great talk about the abuse he personally experienced as a member of the Perl community. I've never experienced abuse in this or any other technology community, but I have experienced abuse before in other contexts. Also, as a disclaimer, although I'm sure many have seen some of Sawyer's situation play out in public, I haven't, as I believe it happened during my extended break from Perl and development in general.

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

More prototype play: Dispatch::Fu

I was seeing this so much talk about smartmatch or given/when, I decided to experiment with a prototype powered pseudo structure I'd been thinking about. The results were pleasing to me, and I plan on releasing this soon. I could rename it to match/case (versus fu/on), but the huffman in me likes the short (and semi-ambiguous) "keywords". Let me know what you think in the comments below.

I still need to do more unit tests, POD, dist.ini, etc. But it's the closest I could get what I was observing on P5P. And the current implementation is about as fast and tight as I think it could be. I also enjoy using Perl's datatype coercion capabilities via prototypes* quite a bit. It is a very powerful, underutilized, and misunderstood capability that can be used to bring about a lot more ideas via a "keyword" experience (which is the entire point).

https://github.com/oodler577/p5-Dispatch-Fu

DESCRIPTION

Why we use Perl at our company

I've been programming in Perl for almost two decades now. A lot has changed in Perl, and also in the way I program with it.

Several years ago my partners and I started a software company, I was in charge of everything to do with tech, so as CTO it was my responsibility to choose the tech stack our company was going to use. And it was an easy one: Perl.

Years have gone by, our company has continued to grow, our product catalogue has increased and the amount of data processing and analysis we do it's exponentially higher than when we started. And Perl has continued to show what a great option it is.

I would like to list some of the reasons why Perl has been such a great fit for our company.

Versatility

Perl v5.36, Debian, and Ubuntu

I normally only write about the Perl Weekly Challenge/The Weekly Challenge, but today I have a couple things to say about recent Perl versions. I've been watching the videos from TPRC2023, and loving the talk by Paul Evans What's New in Perl v5.38. I like to have a minimum version in my code generally that I can rely on having all the features from. I think I previously ignored v5.36 because it wasn't in Debian yet (and I typically only use packaged Perl), but thanks to Paul's talk I've really enjoyed looking at the perldelta, where some really groundbreaking Modern Perl changes were made just in the use v5.36 syntax.

Well, now two things have happened. v5.36 is the oldest release still officially supported by the Perl team, and it's in Debian stable. This makes it a great candidate to be my new target version for most code!

Unfortunately, Ubuntu 22.04 (one of my servers) is still stuck on v5.34, and this makes me sad. 😥

In related news, the new object system in v5.38 and beyond looks pretty sweet! I'm excited. Can't wait to see what else gets implemented in the next couple versions.

Perl Weekly Challenge 236: Array Loops

These are some answers to the Week 236, 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 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 2: Array Loops

You are given an array of unique integers.

Write a script to determine how many loops are in the given array.

To determine a loop: Start at an index and take the number at array[index] and then proceed to that index and continue this until you end up at the starting index.

Example 1

Matching simply

A little over ten years ago, when Perl 5.18 was approaching its release date, I released match::simple. This was mostly in response to the smartmatch operator (~~) being deprecated, but also a solution to the incredibly arcane rules for how the smartmatch operator operated.

match::simple was intended to be... simpler. The operator looks a little funky because it uses some clever trickery to fake being an infix operator:

    use match::simple;
    
    if ( $this |M| $that ) {
        ...;
    }

When Saif Met Sarah

The Perl and Raku Conference 2023

The Perl and raku Conference 2023 in Toronto was an event I was really looking forward to. A chance to rub shoulders with the giants of Perl and Raku, absorb insights and innovations of the nerdy Perly community...everything they said in the blurb. It was very well organised thanks to Alex, Sawyer, Makoto, Amber and Peter, herding an army of volunteers. Such a knowledge-intensive event should be recorded for posterity, trapping the wisdoms and inspirations from the wise and inspiring in the container that is YouTube.

TPRC Toronto Part 3 The End Game

Well a nice banquate last night with good food and good company but a little sad that it was the last day.

To start off I atennded Sawyer X rather sad talk 'No one is Immune to Abuse' I cannot give this talk do justice in a short blog post so I suggest you seek out the recorded talk when it comes out. I will see if I can repost it here once it comes out. It had a large number of lessons for all of us in the Perl comunity.

Next up was me but unfortunetly I have some connection errors and had a little shorter talk and but both of the attendees gave me good feedback ;) oh well that is what happens when you are scheduled at the same time by two of the 'Big Wigs' in the Perl community. Luck of the draw I guess.

Perl Weekly Challenge 235: Duplicate Zeros

These are some answers to the Week 235, 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 September 24, 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: Duplicate Zeros

You are given an array of integers.

Write a script to duplicate each occurrence of ZERO in the given array and shift the remaining to the right but make sure the size of array remain the same.

Example 1

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

Example 2

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

Example 3

Of Go, C, Perl and fastq file conversion Vol I : intro

Next Generation Sequencing (NGS) has really taken off the last few years, as both devices and the cost of experiments have dramatically declined. NGS decipher the identity (base composition, the sequence of letters in the alphabet of DNA and RNA) of nucleic acids and return the results in the fastq open data format. Fastq files are flat text files with a standardized layout: each molecule present in the sample that is captured by the sequencer is represented with four fields:

  1. a '@' character and is followed by a sequence identifier and an optional description

  2. one (typically) or more lines of characters in the four letter alphabet of nucleic acids

  3. a metadata field starting with the "+" optionally followed by the same sequence identifier and description as in the first field

  4. one, or more lines of the quality of each symbol sequence reported in field 2

An example of such a four field entry may look something like this

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

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'

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.