Perl Weekly Challenge 192: Binary Flip and Equal Distribution

These are some answers to the Week 192 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 November, 27, 2022 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.

Task 1: Binary Flip

You are given a positive integer, $n.

Write a script to find the binary flip.

Example 1

Input: $n = 5
Output: 2

First find the binary equivalent of the given integer, 101.
Then flip the binary digits 0 -> 1 and 1 -> 0 and we get 010.
So Binary 010 => Decimal 2.

Example 2

Developing A Game Engine with Perl: Part 6 - A Colourful Telnet Server

I'll stop reminding you that... I DO NOT KNOW WHAT I AM DOING.

If you want to start reading from the beginning. Check out the first article in this series

What is ANSI Game Engine?

Well, at it's core, ANSI Game Engine is a very colourful and interactive telnet server.

Why telnet!?

Closures

A casual remark about closures which I made in My Favorite Warnings: redefine touched off a long off-topic exchange with Aristotle that I thought ought to be promoted to a top-level blog entry. The big thing I learned was that any Perl subroutine can be a closure. The rest of this blog will try to make clear why I now believe this. The words are my own, as are any errors or misconceptions.

The second sentence of Wikipedia's definition of a closure says "Operationally, a closure is a record storing a function together with an environment." This makes it sound a lot like an object, and therefore of little additional interest in an O-O environment.

Addressing CPAN vulnerabilities related to checksums

This blog post addresses checksum and signature verification vulnerabilities affecting CPAN, the cpan client, and the cpanm client, which were published in a security advisory on 23rd November 2021. If you're not aware of this topic, you might like to start by reading the advisory. This post gives a high-level description of the issues, what has been done to address them, what is still left to do, and what you should do. If you have any questions on this, you can add comments here, or email the PAUSE admins (modules at perl dot org).

Before we dig into the details, we'll first give an overview of how the relevant parts of the CPAN ecosystem work.

If you're not interested in the details, skip to the section "What do you need to do?"

TL;DR: make sure your CPAN client uses https and a trusted mirror – such as cpan.org

Perl Weekly Challenge 191: Twice Largest and Cute List

These are some answers to the Week 191 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 November, 20, 2022 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.

Task 1: Twice Largest

You are given list of integers, @list.

Write a script to find out whether the largest item in the list is at least twice as large as each of the other items.

Example 1

The Weekly Challenge - 1000 days

https://theweeklychallenge.org/blog/1000-days/

My Favorite Warnings: deprecated

The deprecated warning is a grab-bag. Basically, anything that is deprecated causes this warning to be generated, and the list changes from release to release.

The only reason I can think of ever to turn this off is around a deprecated construction while you are actively working to eliminate it. Silencing it and then forgetting about it will bite you, eventually.

For the curious (and to run my word count, since otherwise this would be a really short blog entry), the current list of deprecations according to the 5.34.0 perldiag is:

Vale, David

David H. Adler passed away yesterday.

David was a gentleman and a scholar: a gentle, warm, erudite, funny, clever, and deeply kind man. And one who has made a vast contribution to our Perl and Raku communities over more than quarter of a century.

My most sincere condolences to David's family...and to the countless other colleagues, acquaintances, and admirers around the world who will be mourning him today.

Like so many others, I was proud to call David my friend.
I will miss him profoundly.

Perl Weekly Challenge 190: Capital Detection and Decoded List

These are some answers to the Week 190 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 November, 13, 2022 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.

Task 1: Capital Detection

You are given a string with alphabetic characters only: A..Z and a..z.

Write a script to find out if the usage of Capital is appropriate if it satisfies at least one of the following rules:

1) Only first letter is capital and all others are small. 2) Every letter is small. 3) Every letter is capital.

Example 1

Input: $s = 'Perl'
Output: 1

Example 2

The Quickest Way to Set Up HTTPS

I registered on blogs.perl.org today so that I could comment on posts about object systems. However, the very first thing I encountered was a password page with NO SSL. So, even though I have a ton to say about object systems, my first blog post will instead be about setting up SSL.

(I’m aware that this is a “legacy server problem” but I also recently learned that it doesn’t matter with traefik.)

In this grand year of 2021 you can add SSL to any site, on any architecture, for free, by adding 3 files to your server, making one small config change to Apache, and running a service. We are truly living in the future.

traefik

is the first file. It comes from https://github.com/traefik/traefik/releases, and there is one for any architecture, for instance:

I finally start to translate Japanese Perl Zemi to English.

I finally started to translate Japanese Perl Zemi to English.

Perl Zemi | Perl Zemi|Perl Installation, Perl Tutorial, Many Examples

Perl Zemi is Japanese Perl Tutorial site which is well known and red in Japan. Most of all Japanese Perl users know Perl Zemi and read the document repeatedly.

The volume of content is large and has a reputation for being easy to understand.

This site is originally Japanese. I started to translate this site into English at 2021-11 using an automatically translation tool. I plan that the not very good descriptions and examples by the automatic translation will be gradually fixed until 2023-01.

I'm really going to achieve it.

Let's enjoy Perl with me!

TWC 138: Partition-free Weekends

Placeholder for overdue explanation of my solution to Task#2, using regex exponential exhaustion.

Perl Weekly Challenge 189: Greater Character and Array Degree

These are some answers to the Week 189 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 November, 6, 2022 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.

Task 1: Greater Character

You are given an array of characters (a..z) and a target character.

Write a script to find out the smallest character in the given array lexicographically greater than the target character.

Example 1

Input: @array = qw/e m u g/, $target = 'b'
Output: e

Example 2

Input: @array = qw/d c e f/, $target = 'a'
Output: c

Example 3

A dream resyntaxed

[Author’s note: If you’ve read Curtis Poe’s most recent blog post, what follows is going to seem eerily familiar. This post uses the same concepts, arguments, and code examples as his, and reaches exactly the same conclusions. That’s because both posts originate from a long and wide-ranging email discussion between Curtis and myself, as I’ve been privately consulting with him over the past few months on the design of Corinna.

When I read Curtis’s post I almost decided to bin this one, as he managed to cover everything necessary in his usual succinct, eloquent, and engaging style. But he has encouraged me to post my version of this discussion too, as it provides a little more detail on some of the issues we’re addressing, and on the design rationale for the changes we are jointly proposing.

I made a calculator

I created a very basic calculator using wxGlade and the Wx Perl module on CPAN.

wxCalc.png

This is a short one. I've been playing around with wxGlade because it generates Perl code. It is pretty easy to get started on Ubuntu using the base perl.

  • sudo apt-get install wxGlade
  • sudo apt-get install libwx-perl

It took me a while to get the feel of wxGlade, so hang in there. The pay off is when you figure out how to:

  1. build a basic GUI using the builder tools
  2. generate Perl code to just show the GUI (with no actions)
  3. inspect the Perl code
  4. run Perl code
  5. start defining the event handlers

It also takes some time to get an idea about how the Perl code via wxGlade gets injected into the Perl file. I recommend experimenting with the different places in wxGlade you can put in code.

Creating the All Important Flow

The Ephemeral Miniconf

The Ephemeral Miniconf is planned on thursday 18th of november 2021!

Have you heard about The Ephemeral Miniconf ?

flyeren2small.png

It's a Perl/Raku free and online miniconf that will take place on Zoom!
Think "TPRCiC" but smaller with only one track :)

I'm honored to have some experienced speakers about Perl, Github, Devops, LDAP etc... You will enjoy I promise!

More informations on my big blog serie about on devto or on the website.

I can give you already the connections informations:

Meeting ID: 818 6906 5466
Pass: 42

It's planned at 3pm UTC+1(Paris time) so check the timezone planner to know when it is for you.

It's in the morning if you're in US, in the afternoon if you're in Europe and very late if you're in Asia or Australia (sorry).

The planning will be something like this:
planningsmall.png

(it could last longer or change a bit inside the range, like shifting talks, but at the moment here it is)

I'm also possibly preparing some surprises that I don't want to reveal for now.

So my message is basically, it's coming, book your calendar and I'm looking forward to see you at The Ephemeral Miniconf!

Perl Weekly Challenge 188: Divisible Pairs and Total Zero

These are some answers to the Week 188 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Task 1: Divisible Pairs

You are given list of integers @list of size $n and divisor $k.

Write a script to find out count of pairs in the given list that satisfies the following rules.

The pair (i, j) is eligible if and only if
a) 0 <= i < j < len(list)
b) list[i] + list[j] is divisible by k

Example 1

Input: @list = (4, 5, 1, 6), $k = 2
Output: 2

Example 2

Input: @list = (1, 2, 3, 4), $k = 2
Output: 2

Example 3

Input: @list = (1, 3, 4, 5), $k = 3
Output: 2

Example 4

Developing A Game Engine with Perl: Part 5 - 32bit -> 64bit & Perl's Storable

If you haven't heard already... I DO NOT KNOW WHAT I AM DOING.

My Favorite (?) Warnings - Ex-Warnings

Warning categories have proliferated since the warnings pragma was first introduced in Perl 5.6: from 50 in Perl 5.6.2 to 79 in Perl 5.35.5 (the latest as of this writing). But warnings have been removed as well as added. This post documents these -- mostly for historical interest on my part.

Monthly Report - October

In the festive mood again ...

The festive season began already and I miss celebrating festivals with family and friends. But this is nothing new, I should get used to it now. Still sometimes it hurts really bad after all we are humans. In the past, we tried to be with family during festive season. The truth is it didn't feel the same. I don't know why. Could it be we are no longer carefree souls? But that can't be true. I have seen some of my friends on Facebook sharing celebration moments with family. It looks so beautiful and cute. The only difference I can think of is that they with family and I don't.

I would like to mention one friend from Nepal. We never met but I always watch his Facebook post having great time with his family. I think we became friends because of common love for Perl.

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.