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

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:

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.

Why I love Perl 6

I've been quietly playing along at home with the Perl 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 Perl 6:


1..∞ ==> map {$^n²} ==> first {.comb.unique ≥ 5} ==> say();

But the elegance of that solution is not why I love Perl 6.

I love Perl 6 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 Perl 6 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 5, 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.

SPVM CPAN Testers

If you konw the way, please tell me it.

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.

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):

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 Toolchain Summit and PAUSE Permission Management Per Distribution

At the Perl Toolchain Summit 2019 in Marlow/Bisham, I added a feature to manage PAUSE permissions per distribution, which I hope makes it easier for you to grant permissions to other contributors.

This was the fifth year of my PAUSE hacking. I had spent first two years to port PAUSE web interface from mod_perl to Plack to get rid of deprecated tools, and another two years from Plack to Mojolicious for more structure and understandability. PAUSE on Mojolicious was deloyed into production at the 2018 summit (I'm sorry I couldn't report this last year). However, it was still checked out from my mojo_wip branch, and fell back to the old PAUSE on Plack from time to time, e.g. when something weird was found in my branch, or to use new maintenance tools my branch didn't have. One of my goals this year was to resolve this issue.

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.

Stupid Unicode Trick: Noncharacters

Perl RT 133292 is a request to expose the internal perl subroutine that does string interpolation, so that one does not need to figure out how to double-quote a string (escaping where necessary) when feeding it to eval() as a quick-and-dirty templating system.

In fact, there is no such subroutine (the parser makes an interpolation into a concatenation), and anyway why not just use sprintf()?

For someone determined to dive down this rabbit hole, though, Unicode offers another way out: use generic quotes; that is, qq, but delimit the string with a noncharacter. This was suggested to me when I saw the Incompatible Changes section of the Perl 5.29.0 perldelta (1). They're making unassigned code points illegal delimiters? They were legal before??? What else is legal that I did not know about????? (2)

Reusing data with YAML Anchors, Aliases and Merge Keys

I just added a feature called "Merge Keys" to YAML::PP. No Perl YAML module supports this so far. You can merge mappings defined elsewhere in your YAML document into other mappings with that. Here is a short example:

PAUSE Projects at PTS 2019

Every year at the Perl Toolchain Summit (PTS), there is some work done on PAUSE, but 2019 was a vintage year. In this blog post we'll remind you exactly what PAUSE is and does, and then take you through the major bits of PAUSE work done.

This blog post is brought to you by ZipRecruiter, who were a Gold sponsor for the PTS. More information about ZipRecruiter is provided at the end of this article.

MTA-STA for Exim, thanks to Perl

MTA-STS (RFC8461) is a new standard that makes it possible to send downgrade-resistant email over SMTP. In that sense, it is like an alternative to DANE. It does this by piggybacking on the browser Certificate Authority model.

There is a validator here which defaults to checking gmail.com, and possibly can answer your questions about it without the "tl;dr" factor of the RFC.

This perl script was posted on the Exim mailing list, and is designed to work with the Exim Perl interpreter. On demand, this script will check if MTA-STS data is in a LMDB database. If it is not then it will poll a domain for MTA-STS info and put the info into the database. Then, respond to EXIM with required info for processing the outgoing email.

This script provides reboot resistant caching of MTA-STS data. And if the database is not found, it will reconstruct the database and restart the caching.

Exim is the most popular MTA to if you are running your own mail server this is a good chance you are using it.

The link again: https://github.com/Bobberty/MTASTS-EXIM-PERL

Map::Tube v3.62 - UPDATE

One thing about Map::Tube that kept annoying me for long time, is not able to format the result of search without bending the back. Let me share the details what I am talking about. Earlier, before v3.62, this is what you would had to do to format the result.

use strict; use warnings;
use Map::Tube::London;

my $map = Map::Tube::London->new;
my $route = $map->get_shortest_route('Baker Street', 'Wembley Park');
print $map->to_json($route);

We have a plugin Map::Tube::Plugin::Formatter that provides the functionalities. It currently supports the following formats.

1. XML
2. JSON
3. YAML
4. STRING

If you noticed the line "print $map->to_json($route);", this is plain ugly, in my opinion and I always wanted to clean up. Yesterday, I finally got that done. Now the above code can be simplified as below:

use strict; use warnings;
use Map::Tube::London;

my $map = Map::Tube::London->new;
my $route = $map->get_shortest_route('Baker Street', 'Wembley Park');
print $route->to_json;

Or even one-liner like below:

use strict; use warnings;
use Map::Tube::London;

print Map::Tube::London->new->get_shortest_route('Baker Street', 'Wembley Park')->to_json;

I am sure, there is still scope for improvements but for now, I am happy.

Any suggestions?

YAML and more at the Perl Toolchain Summit 2019

This year, I was happy to hear I would be invited again to the Perl Toolchain Summit, an annual event with about 30-35 people hacking four days on toolchain related stuff, improving user experience.

This time it was held in Marlow, a small city two hours from London, in an old abbey which was beautiful (but cold!).

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.