Perl Weekly Challenge 010: Roman Numerals
Write a script to encode/decode Roman numerals.
This has been solved many times, you can easily google a golfed solution shorter than L characters (for example at code-golf.io).
Monthly Report - May
It was the month of Ramadan (Fasting) for us. As always, I was low in energy through out the month. Having said that "Perl Weekly Challenge" kept me going. However there was one low point when my daily CPAN game got discontinued after 621 days of daily CPAN upload. This time, it wasn't my fault. PAUSE site was down for some maintenance work. By the time it came back, it was too late. I really had to motivate myself hard to start again. I must say it wasn't easy to convince myself to start the journey again. I would like to thank everyone for the moral support. As of today, I have done 27 days of daily CPAN upload. With all these happenings, my other pet project "London Hack Day" is being delayed further.
Let's take a quick look through last month main activities.
- Pull Request
- Git Commits
- Perl Weekly Challenge
- Pull Request Club
- Perl Blog
- PerlWeekly Newsletter
- Adopt CPAN Module
Pull Request
25 years of Perl 5 releases
It has been about 25 years since the release of 5.000 (1994), we (The Perl Shop) are thinking about creating an infographic for the Perl 5.30.0 release. This infographic would be an advocacy item aimed at casual Perl users and people outside the community, rather than day-to-day users who would largely be familiar with Perl trivia.
The idea would be to highlight not just some of the stats from that specific release, but to draw attention to the history of 5.x releases by showing how many releases there have been, their frequency, the odd/even dev/prod pattern, and generally that Perl is still being regularly updated with new capabilities, despite the constant 5.x release number.
It might also be good to include a timeline showing notable 5.x releases, indicating when they happened and why they were notable.
What would you include? Post your suggestions below, and cite references, if possible.
Which 5.x releases do you consider notable, and why?
Some known reference material
perlhist is a good source for the date of releases, and it seems to indicate the odd/even scheme was introduced in 2000 with 5.6.
Over in a LinkedIn version of this post, Dave Cross suggested some of his slide decks:
Modern Core Perl
Modern Perl Catch-Up
Perl Weekly Challenge # 10: Roman Numerals and the Jaro-Winkler Distance
These are some answers to the Week 10 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in several days from now (June 2, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.
Challenge # 1: Roman Numerals
Write a script to encode/decode Roman numerals. For example, given Roman numeral CCXLVI, it should return 246. Similarly, for decimal number 39, it should return XXXIX. Checkout Wikipedia page for more information.
Of course, there are some Perl modules on the CPAN to convert from and to Roman numerals, but there wouldn't be any challenge if the idea were to use an existing module.
Most people know more or less how Roman numerals work. They use Latin letters to represent numbers:
German Perl Workshop (GPW) 2019 videos online
English version below
Die Videos vom Deutschen Perl-Workshop Anfang März 2019 in München sind jetzt – weniger als zwei Monate später – online auf YouTube zu finden:
Besonderen Dank an Lee Johnson (LEEJO), der sich um die Aufzeichnung gekümmert hat!
English version:
The recordings from the German Perl Workshop in the beginning of March are now—less than two months later—online on YouTube:.
Obviously most of the talks are in German but you can find some in English, too.
Special thanks to Lee Johnson (LEEJO) who took care of the recording!
berrybrew 1.23 released!
It's been quite a while in the making, but berrybrew version 1.23 now has the ability to "clone" modules from one Perl instance into another.
It's currently a two-step process.
First, berrybrew switch
into the Perl instance you want to export the module list from, then...
berrybrew modules export
This will create a text document in a newly created modules
directory within your Perl installation directory (by default, C:\berrybrew
), named after the version of Perl you exported the module list from (eg: 5.20.3_64
). This file has a single distribution name per line.
You can go ahead and edit this file (remove or add as many distribution names as you like), then when you're ready to import into a different Perl instance, simply berrybrew switch
to it (note that as always, when switching Perls, you must close the command window and open a new one), then:
berrybrew modules import
Creating a Twitter List of CPAN Authors
I've been playing around with how to create a list on Twitter made up solely of CPAN authors. Full post here.
Perl Weekly Challenge # 9: Square Numbers and Functional Programming in Perl
In this other blog post, I provided some answers to Week 9 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Here, I want to use the opportunity of this challenge to illustrate some possibilities of functional programming in Perl (both Perl 5 and Perl 6) using the example of the first challenge of this week..
Challenge: Square Number With At Least 5 Distinct Digits
Write a script that finds the first square number that has at least 5 distinct digits.
A Data Pipeline in Perl 5
One of the solutions I suggested in my above-mentionned blog post was this script:
Why I love Raku
I've been quietly playing along at home with the Weekly Challenge, and this week's first task was:
Write a script that finds the first square number that has at least 5 distinct digits.
The solution to that is (obviously!) to lazily square every number from 1 to infinity, then comb through each square's digits looking for five or more unique numerals, and immediately output the first such square you find.
Which translates directly to Raku:
1..∞ ==> map {$^n²} ==> first {.comb.unique ≥ 5} ==> say();
But the elegance of that solution is not why I love Raku.
I love Raku because, if that solution seems too scary to you (too infinite, too lazy, too concurrent, too pipelined, too Unicoded, too declarative, too functional, too much like something that an Erlang guru would code), then Raku will equally allow you to write a plain and simple version: one that's imperative, iterative, block structured, variable-driven, pure ASCII, and more-or-less exactly what you'd write in Perl, or even in C:
I want to display NA instead of UNKKONW in CPAN Testers
I want to display NA instead of UNKKONW in CPAN Testers.
If you konw the way, please tell me it.
Perl Weekly Challenge 009: Square Numbers and Ranking
Square Numbers
Find the fist square number with at least five distinct digits.
The word “distinct” is translated to “hash” in Perl. Just iterate over the square numbers and count the distinct digits (thanks holli for pointing out starting from 1 makes little sense):
Perl Weekly Challenge # 9: Squares and Rankings
These are some answers to the Week 9 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Challenge # 1: Square Number With At Least 5 Distinct Digits
Write a script that finds the first square number that has at least 5 distinct digits. This was proposed by Laurent Rosenfeld.
Again a challenge suggested by me. I swear that I did not try to solve any of the challenge proposals I sent to Mohammad before submitting these proposals to him. Even the special case of the perfect number challenge of last week is no exception, since, as I explained in my blog post on it, while it stemmed from a CS course assignment of 28 years ago that I solved at the time, the requirement I suggested was markedly different and significantly more difficult.
Managing Your Travis CI Config Files with App::CISetup
App::CISetup can make starting and managing Travis CI config files trivial. Full post here.
I succeeded in creating an executable file of Windows binary.
I succeeded in creating an executable file of Windows binary with SPVM and Strawbery Perl and MinGW.
SPVM is Perlish static language. SPVM modules is compiled to C language, and then it is compiled to executable file of Windows binary.
Compile
perl Makefile.PL gmake perl -Mblib t/exe/exe.t
Execute an executable file of Windows binary
t\spvm_build\work\exe\myexe.exe
This mean that you can write windows native application by Perlish syntax
TIL - Object Method: Named Arguments Unpacking
TIL (or re-learned) how to unpack an object method that has named args, thanks to the Modern Perl book:
my ($self, %args) = @_;
This idiom unpacks $self, then throw the rest of the arguments into %args.
Perl Is Still The Goddess For Text Manipulation
"Ever since I learned Perl during the dot com bubble, I knew that I was forever beholden to its powers to transform.
You heard me. Freedom is the word here with Perl."
Read on: https://towardsdatascience.com/perl-is-still-the-goddess-for-text-manipulation-36e78af3b3fc
Perl Weekly Challenge 008: Perfect Numbers and Centring
This time, the first challenge was more difficult than the second one. So, let’s start with the easier one.
Centring
To centre an array of lines, just find the longest one, and prolong each line on both sides so its length is the same as the maximal one. When printing, we don’t have to prolong the right hand sides of the lines, prefixing the spaces to the left is enough.
#!/usr/bin/perl
use warnings;
use strict;
use Path::Tiny;
use List::Util qw{ max };
sub center {
my @lines = @_;
my $max_length = max(map length, @lines);
return map +(' ' x (($max_length - length) / 2)) . $_, @lines
}
my @lines = path(shift)->lines;
print for center(@lines);
Perl Weekly Challenge # 8: Perfect Numbers and Centered Output
These are some answers to the Week 8 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Challenge # 1: Perfect Numbers
Write a script that computes the first five perfect numbers. A perfect number is an integer that is the sum of its positive proper divisors (all divisors except itself). Please check Wiki for more information. This challenge was proposed by Laurent Rosenfeld.
Stupid Lucene Tricks: Hierarchies
(reposted from the now-sadly-extinct http://use.perl.org/use.perl.org/_Mark+Leighton+Fisher/journal/40449.html)
You can search on hierarchies in Lucene if your hierarchy can be represented as a path enumeration (a Dewey-Decimal-like style of encoding a path, like "001.014.003" for the 3rd grandchild of the 14th child of the 1st branch).
For example, a search phrase like:
hierarchy:001
would return only the direct children of the 1st branch, while:
hierarchy:001*
would return all descendants of the 1st branch.
To get only the children of a particular node, you specify only that node, like:
hierarchy:001.014.003
To get all of the descendants you specify everything that starts with that node:
hierarchy:001.014.003*
To get only the descendants after the children (grandchildren, etc.), you specify:
hierarchy:001.014.003.*
2019-05-21: I haven't tried it, but it looks like you could do this right in Perl with the now-quiescent Apache Lucy loose port of Lucene.
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.