Perl Weekly Challenge 245: Largest of Three

These are some answers to the Week 245, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Task 2: Largest of Three

You are given an array of integers >= 0.

Write a script to return the largest number formed by concatenating some of the given integers in any order which is also a multiple of 3. Return -1 if none found.

Example 1

Input: @ints = (8, 1, 9)
Output: 981

981 % 3 == 0

Example 2

Input: @ints = (8, 6, 7, 1, 0)
Output: 8760

Example 3

Input: @ints = (1)
Output: -1

What does ChatGPT think about improving Perl?

For kicks I asked GPT to speculate about how we might improve Perl syntax with types and better object orientation. It generated the follow code and descriptions. Yes I know there's some errors in the code, I'm just presenting this as Chat GPT wrote it.

FWIW it looks a lot like what I see coming out of Corrina.

JOHN: If you wanted to improve Perl by adding types and object orientation what would you do. Give an example.

CHATGPT: Perl already has a limited form of object orientation, and there are also ways to add type checking through modules like Type::Tiny and Moose. However, if you were looking to significantly improve Perl's support for types and object orientation, there are a few different directions you could take.

Inevitable Improbabilities

Guys anything can happen. There is literally no way of avoiding something that you haven’t prepared for. So in the face of mounting anxiety over the huge number of unexpected scenarios that may be around the corner, what can you do? You can contemplate insulating yourself, try and minimise the hazards, control your environment to a fine level of detail so that the surprises are infrequent and hazards are mitigated. At work I am drowned in Health and Safety Guidance, IT security protocols, Fire Safety Training. This means that work is to a large extent a somewhat boringly protected environment for me, my colleagues and my patients. Yet, even this can not avoid surprises. So what about your home, sitting in front of your computer. All the protection provided by protocols here are more vague, less policed, seen more as guidelines rather than mandatory.

The worst enemy

PayProp supports the German Perl/Raku Workshop 2023

PayProp is an automated payment and reconciliation platform specific to the lettings industry that is both easier to use and more powerful than solutions offered by banks and traditional software vendors.

Perl Weekly Challenge 245: Sort Language

These are some answers to the Week 245, 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 December 3, 2023 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 Language

You are given two arrays of languages and its popularity.

Write a script to sort the language based on popularity.

Example 1

Input: @lang = ('perl', 'c', 'python')
       @popularity = (2, 1, 3)
Output: ('c', 'perl', 'python')

Example 2

Input: @lang = ('c++', 'haskell', 'java')
       @popularity = (1, 3, 2)
Output: ('c++', 'java', 'haskell')

Sort Language in Raku

The Perl Toolchain Summit 2023 has a COVID Policy

The Perl Toolchain Summit is the annual event that brings together the key developers working on the Perl toolchain. The 13th summit (after a three year hiatus in 2020-2022) is in France this year, in late April.

It is, at its heart, an in-person event: about thirty people will spend four days in confined spaces, exchanging ideas and patches. And also droplets. To keep everyone safe, we have prepared a COVID policy.

This week in PSC (097) | 2023-02-10

PSC met today, just Paul and Philippe.

We discussed:

  • inclusion of TLS libraries in the core: we think we should just try the “dual life” path, and see where that gets us.
  • n-at-a-time map/grep: Paul suspects it’s impossible to properly disambiguate my ($var, ...) from the EXPR case, and we wonder if the only choice is between having new keywords and dropping the EXPR case.

Find expiring SSL certs using curl, Go and Perl.

Just like domain name registrations, SSL certificates need to be renewed regularly, otherwise they expire. This means you now have one more thing to monitor. Let's look at ways to do this in Perl, curl and Go. We'll also get a quick introduction to a hosted Mojolicious app that I wrote to make this even easier.

Read the full post.

Perl Weekly Challenge 244: Group Hero

These are some answers to the Week 244, 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 November 26, 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: Group Hero

You are given an array of integers representing the strength.

Write a script to return the sum of the powers of all possible combinations; power is defined as the square of the largest number in a sequence, multiplied by the smallest.

Example 1

New Dancer, Dancer2 plus Ecosystem Updates

Welcome to 2023 (just a little bit late)! We've put together a number of long overdue updates for Dancer, Dancer2, and other parts of the ecosystem.

Dancer2 version 0.400001:

This week in PSC (096) | 2023-02-03

Just Paul and Philippe this week.

  • Smartmatch deprecation continues — just one more distribution left now (Test-Simple).
  • RFC process needs a new name and ID allocation scheme. We will continue discussing ideas and post when we have something presentable.
  • overload::v2 feels like the best solution to the problem of how to add substr overloading.
  • join overloading might want a join_uses_concat flag to avoid surprising existing modules.

United-domains supports the German Perl/Raku-Workshop

We are happy to announce that united-domains
supports the German Perl/Raku-Workshop!

united-domains ist ein erfahrenes Team von mehr als 80 Domain-Spezialisten, die sich zuverlässig und mit Leidenschaft um die Domains unserer Kunden kümmern. Wir inspirieren Brands und Professionals, ihre digitale Identität zu entwicklen.

Perl Weekly Challenge 244: Count Smaller

These are some answers to the Week 244, 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 November 26, 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 Smaller

You are given an array of integers.

Write a script to calculate the number of integers smaller than the integer at each index.

Example 1

Annotated Test2::Tools Index

I have very gradually been adopting Test2::V0 as a testing tool. I had a test file that performed a group of tests inside a for loop, and discovered there were circumstances where I wanted to skip an iteration. Well, the skip() provided by Test2::Tools::Basic operates by executing last SKIP;. In the case of a labeled for this skips not only the current iteration but all subsequent iterations.

I wondered if there was a Test2::Tools plugin that did a next SKIP;, so I generated an annotated index of Test2 tools. This index reports all of them in ASCIIbetical order, with the distribution they are found in and the abstract from the =head1 NAME section of the POD.

Egad I have been a lazy Sod

Yep been a while since I posted something, been playing about with my HAM gear too much these days, but I do have a little gem of wisdom to share so here it is.

I updated my Mojolicious for the first time in quite awhile and my personal web server died.

Well this on was 100% my fault as the error was

Can't locate object method "route" via package "Mojolicious::Routes" at /johns/perl/Mojolicious-Plugin-Routes-Restful-0.03-2/blib/lib/Mojolicious/Plugin/Routes/Restful.pm line 124.

So I had a snoop around Mojolicious today and found this in the change log

8.67 2020-12-04
- Deprecated Mojolicious::Routes::Route::route in favor of Mojolicious::Routes::Route::any.
- Deprecated Mojolicious::Routes::Route::over in favor of Mojolicious::Routes::Route::requires.
- Deprecated Mojolicious::Routes::Route::via in favor of Mojolicious::Routes::Route::methods.

Color Evolution

The most requested feature of the Cellgraph is now in operation: Colors.
blau.png

I added one panel with all the options and functions to control them. It is a little complex, but well documented (see here). In short you can load and save from and to the config file single colors and color sets under special names. And then you have direct access to the gradient and the complimentary function of Graphics::Toolkit::Color. Reverting to the default grayscale is always possible with an push on a button.

Perl Weekly Challenge 243: Floor Sum

These are some answers to the Week 243, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Spoiler Alert: This weekly challenge deadline is due in a bit more than a day from now (on November 19, 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: Floor Sum

You are given an array of positive integers (>=1).

Write a script to return the sum of floor(nums[i] / nums[j]) where 0 <= i,j < nums.length. The floor() function returns the integer part of the division.

Example 1

PDF document creation with Markup languages

New, powerful features have recently been added to PDF::Builder and PDF::Table, enabling faster and easier high-level generation of PDF documents. The versions are respectively 3.025 and 1.005, and are available on CPAN.

This week in PSC (095) | 2023-01-27

A busy meeting today, we talked about quite a few things:

  • Smartmatch deprecation continues. Some upstream PRs have been raised, awaiting CPAN releases
  • Refaliasing might be able to be deëxperimentalized if we add a warning on the currently-failing closure capture cases
  • RFC0013 highlights a deficiency in the overload.pm API shape. Perhaps an opt-in new calling convention is required to make it more flexible. Paul will write another post to the mailing list with more detail
  • Mithaldu’s objection to the suggestion to deprecate map EXPR, LIST suggests that maybe a more powerful debugger “run until next statement” command would be good
  • The interaction of List::Keywords + autovivification highlights the overall problem with highly-pluggable extensible systems - sometimes extensions conflict. We just have to keep this in mind and not have too high expectations that “everything will be fine if we load 20 different plugins”
  • That said, maybe there are some CPAN extensions that ought to be part of the core language - autovivification for example
  • We’ve run out of devel release volunteers now. We need some people to volunteer for 5.37.9, .10, .11, (maybe .12?). Also maybe 5.38.0

My Favorite Modules: PerlIO::via

OK, I confess: PerlIO::via is not a module that I use every day. It allows you, easily, and with minimal code, to modify an I/O stream before it gets to the reader of the stream. or after the writer has written it. All you do is write (say) My::Module conforming to the parts of the PerlIO::via interface you need, and provide it to the second argument of open() or binmode() as ':via(My::Module)'. How cool is that? And how cool is a language that lets you do that with a minimum of fuss, bother, and code?

I encountered this when trying to modify (OK, hack) the behavior of a large and complex hunk of Perl not under my control. Rummaging around in this turned up the fact that all file input went through a single module/object, which had an open() method. I realized if I could insert my own PerlIO layer into the input stream, I would have control over what the victim host code saw.

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.