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

Curated list of Perl modules

See Perl.html
It's an example of the fabulous TiddlyWiki (tiddlywiki.com), so it's about 230,000 bytes.

This week in PSC (125) | 2023-11-23

The PSC met today. In summary:

  • Paul’s TPRF grant was accepted, he plans to spend some of that time to work on some PPCs first (qt strings, overload)
  • FOSDEM Perl Devroom CfP: none of us are planning to attend in person, but if someone else wanted to present on our behalf we could coördinate with them and work out a subject to talk about
  • Discussed coming up with a Perl roadmap that we could present to the world (and entice sponsorship for TPRF’s Perl Development Fund and Grants program)
  • We discussed opening up our meetings to the occasional guest, so they could see what we’re actually doing (boring!) and give us an outside perspective

An Option for Syntax Highlighting on blogs.perl.org

I've struggled with the syntax highlighting here on this blog. I really want to use this site and I will continue to do so.

After trying in vain to get some "auto" syntax highlighting here via the editor, I reached for an old trick I've used in the past. Generating HTML using some external service. After a quick Google search, I found https://tohtml.com/perl/. Given a block of Perl code, it'll generate HTML based syntax highlighting that one may add to their post. For example,

Decent Syntax Highlighting (from tohtml.com/perl)

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

German Perl/Raku Workshop 2024

(English below)

Der nächste Deutsche Perl/Raku-Workshop wird vom 15. bis 17. April 2024 in Frankfurt stattfinden. Damit wir interessante drei Tage mit Perl und Raku verbringen können, brauchen wir Vorträge und Teilnehmer... Vortragsvorschläge könnt ihr bereits einreichen und auch anmelden könnt ihr euch schon hier...

https://act.yapc.eu/gpw2024

The German Perl/Raku workshop will take place
on the 15th to 17th April 2024 again in Frankfurt am Main.
We will spend three interesting days with Perl and Raku, so you are invited
to participate and also to give presentations.

You can submit your presentations here

This Week in PSC (124)

This week we:

  • Reviewed some recent email threads:
    • Returning values from require multiple times - seems not useful as compared to using do FILE or the new load_module builtin
    • CPAN.pm observed to use lots of memory, but also complicated to fix. It might benefit a new smaller simpler tool being provided by Perl core
  • Perl 5.39.5 is due soon and we have release managers up to 5.39.8, but we’re still in need of folks to do up to 5.40.0

Hai Julia !

I released Juliagraph an interactive fractal painter for Julia and Mandelbrot types of fractal.

first.png

Final Call - 2024 TPRC Science Track Survey

We have had a good number of responses, but would like more. And time is running out! Please take this survey and share with your Perl contacts.

Survey URL: https://forms.gle/DDPWsNqEsZW8AyWX7

The track would target academic and industrial STEM applications, and emulate in some way traditional science conference tracks; meaning the talks would be based on paper and poster submissions. If this came to pass, the Science Perl Committee would also follow up with the publishing of the papers in an official proceedings of this track.

Survey officially closes on Thursday, November 23, 2023. But we would love your feedback!

Sincerely,
Brett Estrade
oodler@cpan.org
Chairman, Science Perl Committee

FOSDEM 2024 Call for Participation

The Perl and Raku Foundation is thrilled to announce that the FOSDEM organising team has accepted our proposal to set up a DevRoom on Saturday, February 3rd 2024. It has been quite a few years since the last Perl DevRoom at FOSDEM. Historically, they have always been well attended and packed.

Time for an Update

Since last time, a lot has happened, and TPRF is excited to help create this venue for sharing news with developers from Europe and across the globe. Many FOSDEM visitors have a background using Perl, but may have missed out on recent developments. Larry Wall himself was a guest speaker at FOSDEM in 2015 to announce Perl 6, which was later renamed to Raku. Much has happened since then, and there is lots to share!

Participation

Dodging the Go loop trap

Ted Unangst:

And now we’re trapped. There’s only one friend variable, constantly changing as we go through the loop, with the most likely result one of our friends will get half a dozen messages, while the other five receive nothing, to the annoyance of both groups.

Funny that Perl got this one right when not only many before didn’t but many since also haven’t.

In Go, as Ted says, they may even change the language to fix it; in Javascript, they already have.

Setting up a free Oracle Database for Perl development

I recently added Oracle Database support to SQL::Inserter (check it out if you'd like simple to use, high-performance inserting to SQL databases). I had not used an Oracle Database since my uni days 20 years ago, so I had to set one up to test it.

Even though Oracle provides a free development DB, the process is not as simple as Postgres/MySQL etc., so I thought I'd document it for future reference.

There are basically two ways you can go, with Oracle providing instructions either for a VirtualBox VM, or Docker. For the purposes of this article, we'll use VirtualBox. If you prefer Docker, you can follow Oracle's instructions and skip the next section.

Setting up the Oracle VM

Oracle provides instructions for setting up a VM with their latest 23c Database.

To sum up, you download and install VirtualBox, as well as the 23c VM image (.ova).

Launch VirtualBox, go to File->Import Appliance and select the .ova file that you just downloaded. You can leave the defaults for the import.

Dancer Advent Calendar 2023

Hey Dancers! We’re doing an advent calendar this year, and we’d love for you to contribute. Tell us your Dancer success story! Write about a project you worked on that used Dancer, a plugin you wrote, a plugin you love, anything.

December is coming fast, so get your ideas in now. Please reply to this post if you’d be interesting in helping with this year’s advent calendar.

Recordings of the German Perl Workshop (gpw2023) are online

After a long time of work, the videos are finally available on Youtube. 20 presentations with a total of 14 hours of airtime review the three days of the workshop and you can watch the things you missed on site.

We would especially like to thank Lee Johnson, who made the recordings, and the presenters, of course, without whom the workshop would not have taken place. The support from our sponsors helps us make the workshop take place.

OTOBO
united-domains
Perl-Services.de Renée Bäcker
Geizhals Preisvergleich
PayProp

The recordings of the German Perl Workshop 2023 are organised in the order of the day in a playlist available at gpw2023.

We are planning the German Perl Workshop 2024 again and are already in the final negotiations. As soon as we have a place and date fixed, we will update this post and also make a separate announcement.

Config::Tiny V 2.30 supports keys with arrays as values

Yes, it's true. Config::Tiny now allows you to assign an array of values to a key.
The docs have been updated to include a new section, ARRAY SYNTAX.
Various examples are documented there and in test files. Sample usage:

[section]
greetings[]=Hello
greetings[]=World!
one=two
Foo=Bar

Note: The 2 lines of greetings can be separated by other lines too.

You access these values like this:
say $Config->{section}->{greetings}->[0];
say $Config->{section}->{greetings}->[1]

This patch was kindly provided by Steven Schoch.

See the Changes file for details.

Perl Weekly Challenge #237 - Carpe Diem

Hello everybody! Welcome back to the Weekly Challenge series, where today we're working on dates again. I like these challenges in particular, for some reason. In this case, we have a rather simple challenge except that it gives us less common date formats than usual.

The challenge gives us a year, month, week(day) of the month, and day of week. Now DateTime provides us with get operations to find WoM and DoW info, but it doesn't provide set operations. For that we need to do a little math. Here's the code below:

Announcing Dancer2 1.0.0

On behalf of the Dancer Core Team, I am beyond excited to present you with Dancer2 1.0.0.

So how did we get here? Why now? I'll cover the specifics in a future blog post, but suffice it to say for now, we're stable, and we've been stable for a long time, but this was never reflected in our versioning. It's beyond time to commemorate that milestone.

If you're expecting big changes, you'll be disappointed that there aren't many on the technical side. Much of what's in this release involves adding some polish in spots, and smoothing out some jagged edges in others. Some important highlights include:

plenv-libdirs

A plenv plugin to add additional include directories to Perl.

This plugin sets the contents of file .perl-libdirs. It hooks into plenv-exec command and every time you run perl or any other command under plenv, plenv-libdirs uses the .perl-libdirs files to set the PERL5LIB environment variable.

plenv-libdirs makes use of .perl-libdirs files in the current working directory and every directory between it and root. Environment variable PERL5LIB has a list of paths separated (like in PATH) by a colon on Unixish platforms and by a semicolon on Windows (the proper path separator being given by the command perl -V:path_sep). When plenv-libdirs collects the paths from .perl-libdirs files, the order of the paths follows the order of the directories. The longer the path to .perl-libdirs file, the higher precedence in PERL5LIB.

Hash of Arrays Deathmatch : Native Perl vs. DBM::Deep vs. Redis

Sometimes one has to make compromises between speed of execution and memory, other times one may not have to be. While working towards a fairly (at least in my mind) complete solution to map Nanopore Sequencing files, I ran against the need to create and access fairly large hash of arrays (think of 1M - 100Mof keys), with each array itself consisting of a a fixed number of elements.
The hash of arrays is a fairly straightforward and fast data structure to create in Perl, the memory overhead can be substantial as the number of keys and values scale upwards. While in my application (at least as envisioned now!) the hash will be created, aggregated over (group by for those into python-pandas or r-data.table vernacular) and then discarded, there are use cases in which the data should be preserved to avoid the computational expensive part of generating them via approximate string matching in biological databases.

Perl Weekly Challenge #236 - Lemonade Stand

Welcome back to another round of the weekly challenge, with just one solution this week. I'm setting up a lemonade stand and need to deal with change. Interestingly, I can only sell one juice per person, so I hope you're not super thirsty!

We can take $5, $10, and $20 bills, and we don't start with any change, so we need our previous customers to provide us with change for future customers. Let's find out if we can make change for a set of customers.

Here's the code:

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.