It's less than one month until this year's Swiss Perl Workshop. Perhaps you would like to join us and maybe even submit a talk? It can be anything Perl, anything slightly related to Perl, or just plain old anything that you've found interesting in technology recently that isn't Perl at all.
This year's workshop wouldn't be possible without the sponsors, so we thought we should tell you a little bit about them:
OETIKER+PARTNER is a Swiss system management and software development company. Employees from O+P are involved in many Open Source Software projects.
Founded in 2001, Humanstate is a private technology services group that provides businesses and organisations in various vertical markets with state-of-the-art web-based software applications integrated with on-demand payment processing. Humanstate owns and manages a global transactional platform that forms the core of all its solutions.
The localtime and gmtime built-in functions are interfaces to the POSIX functions for turning a Unix epoch timestamp into date-time components in either UTC or the system local time. When you want to go the other way, there's Time::Local.
Well, almost.
The localtime and gmtime functions have two quirks as compared to the date-time components humans might expect. The value it returns for the month is 0-indexed, ostensibly so that it can be used directly in a 0-indexed array of 12 month names, and the value it returns for the year is the number of years since the year 1900.
A(m, n) = n + 1 if m = 0
A(m, n) = A(m - 1, 1) if m > 0 and n = 0
A(m, n) = A(m - 1, A(m, n - 1)) if m > 0 and n > 0
I know that Perl6 supports multisubs, but when I see a function definition of this kind, I always think Erlang, where you get pattern matching and multisubs by default. Here’s how it looks:
This week's perl weekly challenge was a lot of fun. First of all, challenge number 2 was a breeze. The challenge was to parse and print the components of a URL. That was easy...
I have been a big fan of Damian Conway ever since I bought his book "Perl Best Practices". With the recent regular blog by him about various tasks from the Perl Weekly Challenge showed us really interesting aspects of the task. The one he blogged, Vigenère vs Vigenère last was really special about Vigenere Cipher. I must admit I didn't know half of what he shared in the blog. I wonder how many knew the Vigenere Cipher wasn't invented by Vigenere.
I think, I owe him a drink next time I meet, as per the English tradition. However, being a practicing Muslim, I can't offer drink, instead I would offer box of chocolates.
In the mean time, I am going to reserve space for him in the weekly blog by name "Damian Corner" where we would talk about his blog.
What else happening these days?
I try to keep myself busy during the week by writing short blogs. In the weekly series "Meet The Champion", we recently spoke to Adam Russell, the winner of Perl Weekly Challenge - 016.
I also blogged about the optional API task which we introduced recently. Check out how Neil Bowers took it to another level. Perl Weekly Challenge - Optional API Task.
A recent Standards of Conduct incident[1] regarding The Perl Conference 2019 (TPC) has been deeply divisive within the Perl Community, and handled so poorly that a "clarification" has since been issued[2].
Spoiler Alert: This weekly challenge deadline is due in several days from now (July 21, 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: Ackermann Function
The common Ackermann function, named after Wilhelm Ackermann, is defined recursively as follows:
A(m, n) = n + 1 if m = 0
A(m, n) = A(m - 1, 1) if m > 0 and n = 0
A(m, n) = A(m - 1, A(m, n - 1)) if m > 0 and n > 0
The function grows very rapidly even for relatively small input values, so you may not want to try to compute it for input values such as 5 and 6. You probably don't even want to try it with the first input parameter (m) larger than 3. It also does a very large number of recursive calls, so that it will tend to be very slow.
Some of you, who know me personally, knows my background and how I managed to reached London in 2000. For others, I belong to a state called Bihar, in India. I was born and raised in the city of Jamshedpur. A city built by Tata. Who Tata? They are well respected Industrial group.
I still remember, outside of Bihar, people don't treat us well if they know you are from Bihar. I can tell you from my own experience when I moved to Mumbai (Bombay) in the year 1997. Because of this, people from Bihar don't disclose their identity. Recently some parts of Bihar got separated and created a new state "Jharkhand". In the process, Jamshedpur now belongs to newly created state Jharkhand. However, I still feel my roots belong to Bihar. It gives me immense pride when I hear nice thing about Bihar.
BackupPC is a high-performance, enterprise-grade system for backing up Linux, WinXX, and MacOS PCs and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain.
Given the ever decreasing cost of disks and raid systems, it is now practical and cost effective to backup a large number of machines onto a server's local disk or network storage. This is what BackupPC does. For some sites, this might be the complete backup solution. For other sites, additional permanent archives could be created by periodically backing up the server to tape. A variety of Open Source systems are available for doing backup to tape.
BackupPC is written in Perl and extracts backup data via SMB (using Samba), rsync, or tar over ssh/rsh/nfs. It is robust, reliable, well documented and freely available as Open Source on GitHub.
Long version: people have been asking me why I've not been as visible in the Perl community as I used to be (including at least one person asking if I was still involved in Perl). Well, that's a long story.
The second task of the 15th Weekly Challenge was to implement
an encoder and a decoder for the Vigenère Cipher. But that’s a
little more complicated than it seems, because the cipher that's named
after Blaise de Vigenère wasn’t actually invented by him, and the cipher
that Vigenère actually invented isn’t named after him.
So should we implement the Vigenère Cipher...or Vigenère’s cipher?
Why not both!
The Vigenère Cipher was devised by Giovan Battista Bellaso in 1553,
and then misattributed to Vigenère about three hundred years later.
It uses a tabula rēcta to translate from a message text to a ciphertext,
and back again.
Given an user-provided key (e.g."BELLASO"), we encipher a message
(e.g."VIGENEREDIDNOTINVENTTHIS") by matching up respective letters of the
key and message, then using them as two indices to look up the corresponding
cipher character in the appropriate column and row of the tabula rēcta.
And if the key is shorter than the message, we just recycle the key
as many times as necessary.
At a party a pie is to be shared by 100 guest. The first guest gets 1% of the pie, the second guest gets 2% of the remaining pie, the third gets 3% of the remaining pie, the fourth gets 4% and so on. Write a script that figures out which guest gets the largest piece of pie.
I started with a straightforward implementation of the specification. Start with the pie of size 1; in each step, find out the size of the corresponding guest’s part, remember it if it’s largest one so far, and decrease the size of the pie.
Now that that's out of the way, I'd just like to go over my solution for this week's Perl weekly challenge.
The first challenge was to divide a pie between 100 people, in a manner where the first guest gets 1/100 (i.e. 1%) of the pie, and the second gets 2/100 (i.e. 2%) of what remained, etc etc. The question is, who got the biggest piece of pie.
If I were better at math, I would prove that the answer is the square root of the amount of guests, because that does seem to be the case. Since I'm not, I solved it procedurally, as follows.
We set up our guests. We allow for the user to pass in a value on the command line, to check values other than 100, but default to 100:
use v5.22; #that's my perl
my $guests = shift // 100;
In this post dated July 8, I provided solutions to the first challenge of Week 16 of the Perl Weekly Challenge organized by Mohammad S. Anwar. At the time, I admitted that I was having trouble understanding the requirement for the second challenge. After quite a bit of googling, I can finally provide some answers to the second challenge of Week 16.
I should acknowledge that I spent far more time on this than I would wish to admit. Far more time than I ever did on any of the previous challenges.
This puzzle’s connection with Pythagoras is tenuous indeed: it originally appeared in the Dutch magazine Pythagoras (see here and here)! But the puzzle is interesting. Of course, the real challenge is to work out the answer mathematically, but for those of us who are mathematically declined a Perl script is the way to go.
The first draft of my solution was tied to the 100 guests specified in the puzzle statement, but it’s easy to extend the puzzle to allow any (positive integer) number of guests. So I include the number of guests as a constant $GUESTS and the central calculation becomes:
$piece = ($guest / $GUESTS) * $pie;
where $guest is any number in the series 1 .. $GUESTS and $pie is the fraction of original pie remaining at this point in the distribution.
Perl 5 solution
For my own interest I added code to display the size of each guest’s piece of pie. This code can be omitted from compilation by setting DEBUG to a false value.
We're back for the final day of the Perl Conference. Wendy and Liz were very much missed this year, but we had enough Perl items to set up a booth, with the help of Ruth Holloway and Peter Sargent. The table was full of buttons, stickers, tuits, and other info from Perl Careers.
On this final day we attended the traditional Q&A with Larry Wall. People were able to send their questions via Twitter, and I asked Larry who his favorite musical composer is.
I'm not a technical person, but I am a violinist, which gives me something in common with Larry Wall! Pretty cool, right? Anyway, Larry's answer was Gustav Mahler. Very good answer Larry, I myself am a Mahler enthusiast. What I remember from this Q&A session is Larry's call for peace and respect. The Perl community has a lot of great people, very different from one another. The things we have in common should always surpass our differences.
DBD::SQLite 1.63_05 (with SQLite 3.29.0) is a release candidate for the next stable DBD::SQLite. There are no big changes, maybe except for two new db_config options to disallow double-quoted string literals.
use DBD::SQLite::Constants qw/:database_connection_configuration_options/;
$dbh->sqlite_db_config( SQLITE_DBCONFIG_DQS_DML, 1 );
$dbh->do('INSERT INTO foo VALUES (1, "text")'); # Now this is an error
I'll wait for about a month as always, and release 1.64 in the middle of August (that means, after PerlCon) if there's no blocker nor request to wait for more. Thank you for your patience.
The first task of last week's Weekly Challenge was to print the
first ten strong and weak primes. A prime pn is "strong" if it's larger
than the average of its two neighbouring primes (i.e.pn > (pn-1+pn+1)/2).
A prime is "weak" if it's smaller than the average of its two neighbours.
Of course, this challenge would be trivial if we happened to have a list
of all the prime numbers. Then we'd just filter out the first ten that
are strong, and the first ten that are weak. In fact, it would be even
easier if we happened to have a list of all the strong primes, and a
list of all the weak ones. Then we'd just print the first ten of each.
But there are an infinite number of primes and of weak primes (and
possibly of strong primes too, though that's still only conjectured),
so building a complete list of the various subspecies of primes
is impractical in most programming languages.