These are some answers to the Week 106 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (April 4, 2021). 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: Maximum Gap
You are given an array of integers
Write a script to display the maximum difference between two successive elements once the array is sorted.
If the array contains only 1 element then display 0.
I got this email from PAUSE just now:
Failed: PAUSE indexer report BKB/Go-Tokenize-0.01.tar.gz
module : switch
It looks like it doesn't like this line of code containing Go keywords:
chan else goto package switch
Folk's in the world of Perl have been making amazing efforts to blog more and even to produce video content. That's awesome! Keep it up!
Risking sounding like a mandatory training video from HR, I want to remind budding authors of some high level criteria you should review before completing a post:
- Does it welcome new people to Perl?
- Does it welcome people back to Perl?
- Does it lift, encourage and praise them?
- Is it respectful to people who's use case, experiences and journey with Perl is different to yours?
- Is it respectful of peoples lifestyle, politics, background, and differing lived experiences?
- Does it grow the Perl community and celebrate our diversity?
- Does it teach people something new about Perl?
The answer in all cases should be yes.
Here are some examples that aren't inspired by any specific post but are based on content or comments I have read.
Using system perl is stupid, it's not real perl
I've released berrybrew version 1.33. This version has significant enhancements, along with some bug fixes and handling of some uncaught exceptions. The changes reflect versions 1.30 to 1.33.
Major changes include:
- Allows you to install, switch to, remove and use Strawberry Perls directly
- Can now spawn a CLI window for any Perl you have installed
- Allows you to spawn a CLI window for the currently active Perl
- Provides access to modify several of the core configuration options (debug, file association etc)
- Allows you to disable all berrybrew Perls and restore to system default
- Performs an upgrade on any previous berrybrew install
- Adds any new configuration options, while preserving the values of any previously set existing ones
- Provides facility to install the most recent version of Strawberry Perl
- Allows you to have berrybrew manage the .pl file association
- Allows you to have the UI run at system startup
- Aborts if trying to install the same version that's already installed
- You can now leave off the 32/64 bit prefix on a Perl name, and we'll default to _64
- All execution paths return a proper exit code
- Added new berrybrew hidden command, lists all, well, hidden commands
For all other changes, please refer to the Changes file.
These are some answers to the Week 105 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 28, 2021). 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: Nth Root
You are given positive numbers
Write a script to find out the
$Nth root of
$k. For more information, please take a look at the wiki page.
Input: $N = 5, $k = 248832
Input: $N = 5, $k = 34
I've written a new blog post on Perl 7 (prev: Perl 7: A Risk-Benefit Analysis and Perl 7 By Default). You can find it, and likely my future posts, on dev.to#perl, for similar reasons as mentioned here.
Perl 7: A Modest Proposal
You can now use the spvmcc command to generate an executable file from the SPVM source code.
SPVM is a module that can convert Perl-like source code into C language and execute it.
I have succeeded in generating an executable in a very stable way.
SPVM source code
I recently became aware of a very cool service provided by the Google. The Civic Information API provides contact information for all elected representatives (from head of state down to municipal official) for any US address.
I wrote the Perl client for the API, published as Net::Google::CivicInformation. Get a free API token and you're up and running.
This was a satisfying project because I can imagine people finding actual value in the product. I'm all for being vocal with our government! I decided to take it a step further and created a webservice interfacing to the API. It's written in Dancer2 and the source code is on Github (at the urging of ++GabSzab who pointed out that there are few examples of Dancer2 apps for developers to study.)
The site is online now at https://contactmyreps.com. Please give it a try. Feedback welcome!
These are some answers to the Week 104 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (March 21, 2021). 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: Fusc Sequence
Write a script to generate first 50 members of FUSC Sequence. Please refer to OEIS for more information.
The sequence is defined as below:
fusc(0) = 0
fusc(1) = 1
for n > 1:
when n is even: fusc(n) = fusc(n / 2),
when n is odd: fusc(n) = fusc((n-1)/2) + fusc((n+1)/2)
Fusc Sequence in Raku
Following on from the Gzip::Libdeflate I mentioned before, I also made this: Gzip::Zopfli
It is based on the Zopfli gzip compression library from Google Research.
Both Zopfli and libdeflate seem to excel at compressing JSON files compared to the ordinary zlib compression, sometimes with an improvement of up to 30%. Zopfli usually wins by a small margin over libdeflate. Here are some results of this script on random JSON files:
Let's look at the brighter side ...
Did you have chance to read my annual report?
I have been doing monthly report for many years now.
Why? What is the point?
Well, let me answer the first question, Why? To be honest with you, I do it to keep myself motivated. I need some kind of (self) motivation to carry on what I do on a daily basis. Now to answer the second question, What is the point? It helps me to keep track and follow the progress.
Well, it’s been a hot minute since the last release, hasn’t it? Dancer2 0.300005 has landed on CPAN and features a number of bug fixes, enhancements, and doc patches:
These are some answers to the Week 100 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Task 1: Fun Time
You are given a time (12 hour / 24 hour).
Write a script to convert the given time from 12 hour format to 24 hour format and vice versa.
Ideally we expect a one-liner.
Input: 05:15 pm or 05:15pm
Output: 07:15 pm or 07:15pm
I've turned the libdeflate compression library into a CPAN module:
This is the gzip compression method, but updated.
It's supposed to be much faster and better than libz (the original gzip library).
Sometimes I am getting compression of as much as 30% better on some files.
So far I haven't tested whether or not it is faster.
See the module above for links to the original library and so on.
Since this is an early release, it's very likely indeed that bugs in the module are my fault rather than any problem with libdeflate, so please report them to me.
The lighting in my bedroom uses Philips Hue bulbs — specifically, the coloured ones. Last night, I decided it would be nice to set the three lights in my bedroom to cycle slowly through a set of warm colours using a script.
I didn't want harsh transitions from one colour to the next, but for the lighting to fade from one colour to the next in a smooth gradient. Also, I didn't want the three bulbs to all be the exact same colour, but wanted each bulb to be at different stage in the cycle, like they're "chasing" each other through the colours.
So I whipped up a quick script. It requires the command-line tool hueadm to be installed and set up before we start. You can run hueadm lights to get a list of available lights, and in particular, their ID numbers.
Let me preface this short post with this, I don't have the solution to this problem. Perhaps there is someone in the wider Perl space who is well placed to pick this up, but there seems to be little going on in terms of community engagement.
In the first week of 2021 I noticed a link to this sunset message for rt.cpan behind displayed on the rt.cpan homepage. Firstly I believe the notification on the page could be highlighted better, grey on grey, on a page with lots of grey isn't exactly eye catching.
At the time the linked article didn't contain much information, besides a date. It has since been updated with links to resources to migrate tickets elsewhere.
These are some answers to the Week 99 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 14, 2021). 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: Pattern Match
You are given a string
$S and a pattern
Write a script to check if given pattern validate the entire string. Print 1 if pass otherwise 0.
The patterns can also have the following characters:
- ? - Match any single character.
- * - Match any sequence of characters.
Input: $S = "abcde" $P = "a*e"
Input: $S = "abcde" $P = "a*d"
The British Royal Family and GameStop have been in a secret war with each other for hundreds of years. Nobody knows why. GameStop has included it in their manifesto and the Royals is always untrustworthy. They leave clues to mock us! GAMESTOP HAS INCLUDED IT IN THEIR MANIFESTO! MOCK! MOCK!
There is more:
Q found out that reincarnation is true and he has been imprisoned in The Pentagon. Qanon are protecting this secret. The Biden administration knows the truth but Qanon have paid them off with a warehouse full of holy water. The Wikipedia entry for The Pentagon keeps getting edited by the Biden administration and Qanon even admit it. They leave clues to mock us.
You too can find out the truth about what's REALLY going on here or here
What is a role? Put simply, roles are a form of code reuse. Often, the term shared behavior is used. Roles are said to be consumed and the methods ( including attribute accessors ) are flattened into the consuming class.
One of the major benefits of roles is they attempt to solve the diamond problem encountered in multi-inheritance by requiring developers to resolve name collisions manually that arise in multi-inheritance. Don't be fooled however, roles are a form of multi-inheritance.
I often see roles being used in ways they shouldn’t be. Let’s look at the mis-use of roles, then see an example of shared behavior.
I’m using that word inheritance a lot for a reason, one of the two ways I see roles most often misused is to hide an inheritance nightmare.
I have created a static archive of rt.cpan.org - it is avaliable at https://rt-cpan.github.io/. This is now what will be the official static archive once rt.cpan.org is sunset.
The static archive is a git repo, hosted using github pages. The repo can be found at https://github.com/rt-cpan/rt-cpan.github.io and it has a README that explains how the archive is/was built and URL structure.
The archive is generally complete, it will be updated one more time before the end of February this year. If you discover any issues then please raise an issue using the github link above. If you need to search the archive then you can do that using the gihub link above also, or git clone it and use the command line.
Happy New Year!