This Week in PSC (138)
Back to the usual three of us
Further chats on allowing a subsequent
use VERSION
of the same value as is already prevailingWe continued going through the bug list to tag release blockers
Back to the usual three of us
Further chats on allowing a subsequent use VERSION
of the same value as is already prevailing
We continued going through the bug list to tag release blockers
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:
These are some answers to the Week 256, 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 February 18, 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.
You are given an array of distinct words, @words
.
Write a script to find the maximum pairs in the given array. The words $words[i]
and $words[j]
can be a pair one is reverse of the other.
Example 1
Input: @words = ("ab", "de", "ed", "bc")
Output: 1
There is one pair in the given array: "de" and "ed"
Example 2
Emacs comes with two different major modes to edit Perl code: perl-mode and cperl-mode.
perl-mode is somewhat stuck with the Perl syntax of 5.14, has less features, but a cleaner implementation. cperl-mode is up to date with Perl 5.38 and has deeper understanding of Perl syntax, but a somewhat arcane implementation, most of it written in the previous century.
With all due respect to TIMTOWTDI, maintaining two major modes turns out to be not enough fun in the long run, and last week Stefan Kangas opened a wishlist item to Making perl-mode.el obsolete.
The mail thread shows that some people prefer perl-mode because it is less "colorful" and intrusive than cperl-mode. Therefore, the idea is to enable cperl-mode to (optionally) look like and behave like perl-mode. That way, perl-mode.el can be obsoleted without making those users uncomfortable: perl-mode would continue to exist as a custom theme of cperl-mode.
Paul was away this week.
Hi everybody, we've got another two challenges this week, so let's dive into them!
The goal is to see if there's any one number that can be removed to make the set sorted in increasing order. Here's the code:
Whohoo release 1.7 (and 1.6) brought a thorough architectural rewrite, new color spaces (HSV, HWB, YIQ), new formats ([named] array, string and css_string), choosable value ranges, closed both open issues, and introduced the named argument API I wrote last time about. And as promised, this post is about the methods: distance, set, add and blend.
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.
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
In the final part of this series, we will test the performance of the four parsers, in a scenario emulating the batch analysis of sequencing data. We will use the sample fastq file 3_OHara_S2_rbcLa_2019_minq7.fastq from https://zenodo.org/record/3736457. This is a 35MB file of 21791 long sequences for a nanopore experiment. Download the data and save them to a directory in your hard disk. Then use the following bash time_fastq2a_shell.txt (change the extension to .sh before running!) to process this file 500 times with each of the four methods : seqtk (C), seqkit (Go), perl - regex (code presented here saved into fastq2a_regex_comp_in_func.pl file) and perl - flag (code presented there saved into the fastq2a_flag.pl file).
CGI::Tiny is a very nice, Perlish way to construct CGI scripts these days. It is perfectly suited as a replacement to CGI.pm and is quite at home in a shared hosting environment.
Here's the example from the POD [1] on metacpan:
use CGI::Tiny; cgi { my $cgi = $_; # set up error handling on $cgi # inspect request data via $cgi # set response headers if needed via $cgi # render response with $cgi->render or $cgi->render_chunk };
I recently coupled this with my new module Dispatch::Fu [2], and it worked exceedingly well. It is a darn pleasure to consider from a distance, if I do say so myself:
Hi everybody! Back this week with a (surprisingly long) solution to just Task 1 of the weekly challenge. Task 2 makes no sense to me at all because it seems like examples 1 and 3 disagree with each other. Just sticking to one challenge for that reason. Anyways, let's dive into it!
The goal here is to find the letters that all the provided words share. Here's the code:
This week, the three of us:
use VERSION
restrictions have had mostly positive responsesData::Printer
can’t go in core as-is, but there’s a use case for a debugging helper, some of which might be hidden in D:P’s corebuiltin::numify
function (and the corresponding OP in core)One of my 'nuts and bolts' modules is constant::more. It declares constants, just like constant , however also gives you the ability to set these values in a consistent way from the command line or environment variables.
This can give module authors constants with 'default values', and allow the top level application code to override from the command line if they choose.
This has worked well for my needs to date. I've just released v0.3.0 with some additional features I feel make it even more useful and might make it more useful for others:
Originally I made the interface only work like constant for simple use cases. This meant multiple constants had to be inside a hash ref of actually multiple use constant::more... lines.
use constant::more {CONST1=>1, CONST2=>2};
Now a flat list is usable, which I personally find much more appealing:
use constant::more CONST1=>1, CONST2=>2;
These are some answers to the Week 233, Task 1, of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on September 17, 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.
You are given an array of words made up of alphabetic characters only.
Write a script to return all alphabetic characters that show up in all words including duplicates.
Example 1
Input: @words = ("java", "javascript", "julia")
Output: ("j", "a")
Example 2
Input: @words = ("bella", "label", "roller")
Output: ("e", "l", "l")
Example 3
We’re excited to announce that Ruth Holloway (GeekRuthie) has joined the Dancer Core Team.
Ruth is a longtime user of Dancer2, and has been one of our most vocal supporters in the greater Perl community. She’s responsible for a number of excellent additions to the Dancer2 ecosystem, and is an active member of our wonderful community.
Please join us in welcoming Ruth to our team. We’re looking forward to her continued contributions to the framework and community.
In other news, Steven Humphrey has retired from the Core Team. We’re grateful for his contributions to Dancer2, and wish him well in his future endeavors.
All three of us returned.
We only had one issue to discuss, the pressing matter of how to handle lexical unimports, builtin
version bundles, the integration with use VERSION
, and various related topics.
It’s complicated. We’ve been putting together a longer mail on the subject and that will come out as its own thread soon.
These are some answers to the Week 255, 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 February 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.
You are given a paragraph $p
and a banned word $w
.
Write a script to return the most frequent word that is not banned.
Example 1
Input: $p = "Joe hit a ball, the hit ball flew far after it was hit."
$w = "hit"
Output: "ball"
The banned word "hit" occurs 3 times.
The other word "ball" occurs 2 times.
Example 2
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)
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.