Object::Pad review Yuki Kimoto's 2021-08-21 - Constructor default argument

I start to review Paul Evans's Object::Pad from my personal thinking.

Latest years, Perl core teams positively try to implement Object-Oriented feature to Perl core. I hope my review helps a little.

First time is constructor default arguments.

Perl Weekly Challenge 177: Damm Algorithm and Palindromic Prime Cyclops

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

Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on Aug. 14, 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: Damm Algorithm

You are given a positive number, $n.

Write a script to validate the given number against the included check digit.

Please checkout the wikipedia page for information.

Example 1

Input: $n = 5724
Output: 1 as it is valid number

Example 2

Input: $n = 5727
Output: 0 as it is invalid number

The algorithm is a check digit algorithm named after H. Michael Damm, who presented it in 2004.

TWC 120: Task #1, Swap Odd/Even bits & Task #2, Clock Angle

TWC Task #1, Swap Odd/Even bits

jaredor submission for Task #1

I was just going to use a variation on last week's "Nybble Swap" task for this, but then I foolishly thought, "No, I've read Hacker's Delight I should twiddle bits!"

Okay, now that I told you about my first mistake, let me tell you, the bit twiddling was fun once it started working but I do have a little regret that it's straightforward bit-twiddling: I created a bit mask to pick out alternating bits, then just did the shifting and OR-ing you would expect to switch the even/odd bits. I can't help but wonder if there isn't some clever one-liner in Hacker's Delight. I can't claim to have remembered it even once though: I skimmed the book.

How I Uploaded a CPAN Module

An updated but yet to be completed version is here.


So, accumulating effort from Wednesday, today(Friday) I become a CPAN contributor!

I got a PAUSE ID 2 weeks ago. If you are also interested in the Perl ecosystem, you may consider to apply for a PAUSE ID as well.

In this blogpost, I mainly follow the instructions here:

Some contents of the PerlMonks article are largely repeated here.

This piece of PerlMonks article is already 19-year-old, but it is still valid. One of the good things of the article is that you need not install new modules or programs if you are on a *nix system.

Prerequisites

One should have some knowledge on modules, packages and, not really necessary, object-oriented Perl ("Perl OO" in short).

Released Giblog 2.0, and a movie "How to create your web site using Giblog and Perl"

Released Giblog 2.0. GIblog is a tool to create your web site easily.

Giblog 2.0 Release Announcement

Giblog 2.0 is released at 2021-7-24. serve command and publish command is added.

Giblog 2.0 Release Announcement

Giblog Document

Giblog Document in CPAN.

Giblog Document

Giblog Movie

I explain how to create your website using Giblog and Perl by live coding. Giblog is a Perl module to create web sites. If you see this movie, you can create your web site using Giblog and Perl(although you need some Linux knowledge).

# Perl Weekly Challenge 176: Permuted Multiples and Reversible Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on Aug. 7, 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: Permuted Multiples

Write a script to find the smallest positive integer x such that x, 2x, 3x, 4x, 5x and 6x are permuted multiples of each other.

For example, the integers 125874 and 251748 are permuted multiples of each other as

251784 = 2 x 125874

and also both have the same digits but in different order.

Output

142857

TWC 119: Les Nybb and the Arrhythmic Trio

In which Raku solutions give shape to Perl solutions, and vice versa, and then Raku does what Raku does best.

Task 1: Swap Nibbles - basic and extended solutions in Raku and Perl.

Task 2: Sequence of symbols 123 without adjacent 1’s. Solutions in Raku and Perl, then a radically different approach that I would have never discovered in anything but Raku.

TWC 119: Task #1, Swap Nibbles & Task #2, Sequence without 1-on-1

TWC Task #1, Swap Nibbles

jaredor submission for Task #1

Hello everyone, I'm back after a year's absence, good to see everything is going as strong as ever. I have some extra time this weekend, so thought I'd try my hand at an answer again.

But, oh golly, looking back over my earlier posts on earlier problems was just painful--too many details! Going forward I'll just broad-brush things (and I mean it this time). If anyone has a question about details, then ask about them in the comments.

The swap nibbles problem is equivalent to a "swap hex-chars problem" and since we have the bigint module then any hex string can be represented by an integer. When a little investigation brought up that every bigint object has an as_hex() method, I found the restriction to positive integers less than 255 too restrictive: I decided to do them all! (Well, not quite all, since there are an infinite number of integers, but you know what I mean.)

Monthly Report - June

Never been so busy ...

As you all know, I have recently started taking part in the weekly challenge again. I have always complained about the lack of time doing things I always wanted to do. But then it doesn't stop me taking up new projects. I have to learn how to prioritize projects. May be one day, I will get there. Right now I am actively working on 2 new projects simultaneously. First is preparing the talk for the upcoming Raku Online Conference. It is going to be my personal journey to Raku. And the second is very close to my heart, working on my first book about Perl in association with Dave Cross.

Perl Weekly Challenge 175: Last Sunday and Perfect Totient Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on July 31, 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: Last Sunday

Write a script to list Last Sunday of every month in the given year.

For example, for year 2022, we should get the following:

Announcing Date-ManipX-Almanac

One of the remarkable things about the Date-Manip package is its flexibility in the matter of input. If I mean "tomorrow noon," I do not have to think of what today is, I simply specify "tomorrow noon," or its equivalent in any of sixteen other languages.

One day, I thought: what about "tomorrow sunrise?" And thus was born Date-ManipX-Almanac.

In principal, there can be support for any almanac event from any astronomical body in the Astro::Coord::ECI ecosystem. In practice at least most of them are covered, though I have not audited for 100% coverage. This includes the bodies in the Astro-Coord-ECI-VSOP87D distribution, should you want planets through Neptune. Pluto was not covered by the VSOP models -- its exclusion is not a political statement, at least not by me. Satellites are not supported, and currently there are no plans for them.

Essence of Perl Text Processing - Perl Book

I published "Essence of Perl Text Processing" in Japan. This is 2021 new Perl Book(Both Normal Book and EBook).

Essence of Perl Text Processing

Mascot character is called Mojigaeru(This means String Frag).

"Kaeru(Gaeru/変える)" also means "replace" in Japanese. This expresses Perl is good at string searching and replacing.

Amazon Web Programming new Ranking #2 in Japan 2021-07-05

Amazon Web Programming new Ranking #2 in Japan 2021-07-05

Don't be ashamed of Perl. Be brave.

CPAN Bus Factor

Perhaps you've noticed a new metric when browsing MetaCPAN?

moose.png

What is "bus factor"?

Wikipedia defines "bus factor" as

a measurement of the risk resulting from information and capabilities not being shared among team members, derived from the phrase "in case they get hit by a bus."

For CPAN our definition is "a measurement of how risky it might be to start relying on a CPAN module, which might not be actively maintained".

Read the full post.

Perl Weekly Challenge 174: Disarium Numbers in dc

This blog is an answer to the first task (Disarium Numbers) of the Week 174 of the Perl Weekly Challenge organized by Mohammad S. Anwar.

Originally, the Perl Weekly Challenge called for solutions in Perl and Raku (also known as Perl 6 at the time). But, very soon, people started to provide solutions in other “guest” languages. See for example my blog post providing solutions to the task described below in about 18 different guest languages.

One of the languages I tried for the first time last week with Sylvester’s sequence is dc, and it turned out to be much more difficult and challenging than I initially thought. One of the problems is that there is only very limited documentation on this old programming language. So I thought it might be useful to describe in some details how I solved it. I provided detailed explanations in this other blog post. I’ll now do the same with the disarium number task of this week, which is a bit more complicated.

Promotion: Knight's Challenge

knight.png(image from wikipedia)
PROMOTION:

A coding puzzle for “The Weekly Challenge ‐ Perl & Raku” I made has been released this week!

You have 46- hours to play with it if you align with official deadline. It probably spends you 2~5 hours in this weekend. Beware! Doing the bonus part may spend you a block of extra 2 hours or more.

I wish more people will participate and show different approaches to the task. (And, may the participant give me some feedback as a puzzle creator?)

One may have advantage if s/he has played chess.

As the puzzle creator, of course I had a sketch of a solution in my mind.

Yesterday I solved (== coded) the puzzle and is blogging about it this morning. [Spoiler Alert] If you are interested in my solution... source code , blogpost

Miscellaneous:

My blog is moved to GitHub, mainly because I think soon or later I will blog on other programming languages or issues. At this moment, it has a few posts. :o)


What they say in Java is just as true in Perl

use Benchmark::Dumb 'cmpthese';

( $bar, $quux ) = qw( bar quux );

cmpthese( 0.0002, {
  conc => q{
    my $str = "xxx ";
    (((( $str .= "foo" ).= $::bar ).= "baz" ).= $::quux ).= "qux";
  },
  intp => q{
    my $str = "xxx ";
    $str .= "foo${::bar}baz${::quux}qux";
  },
} );

Next stable DBD::SQLite will be released around the end of July

DBD::SQLite 1.67_07 (with SQLite 3.36.0) is a release candidate for the next stable DBD::SQLite. This release has a notable change to improve how to deal with Unicode/Latin-1 characters, contributed by Felipe Gasper. If you write a new application, it is recommended to use one of the newly added modes like this:

Perl Weekly Challenge 174: Disarium Numbers and Permutation Rankings

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

Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on July 24, 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: Disarium Numbers

Write a script to generate first 19 Disarium Numbers.

A disarium number is an integer where the sum of each digit raised to the power of its position in the number, is equal to the number.

For example,

518 is a disarium number as (5 ** 1) + (1 ** 2) + (8 ** 3) => 5 + 1 + 512 => 518

Tau Station considered Dangerous: Game Review

I thought I’d try out Tau Station for a couple of days and get a quick blog post out of it. That was three months and 11 levels ago. It took 2 months to wind down my obsessive nature and if not for Tau, I could have pushed a couple of new module versions to CPAN by now. That’s rather the reason that I don’t play games in the first place, so I can’t give great comparisons.

To sum up, Tau Station is a web-based, second-person adventure with resource management in real-time: a Choose-your-own-Adventure book crossed with Freeciv. Oh, and it’s free. Well, freemium, but the least obtrusive freemium game I’ve ever seen.

Live streaming the release of Perl 5.35.1

In my talk at The Perl and Raku Conference in the Cloud 2021,
I already announced it. I'm doing the release of the Perl developer version
5.35.1, and you can watch it live Sunday, 20th June on Twitch.

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.