Perl Weekly Challenge 46: Garbled Message and Room Open

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (February 9, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.

Garbled Message

The communication system of an office is broken and message received are not completely reliable. To send message Hello, it ended up sending these following:

H x l 4 !
c e - l o
z e 6 l g
H W l v R
q 9 m # o

Similarly, another day we received a message repeatedly like below:

Paws XXXII (80+ paws)

Today's post proves that test suite, even one that uses canned data, requests and responses, is a very valuable asset to have about.

As I was charging though some 80 action calls copying the requests from my successful unit tests into my t/09_request.t test cases I ran into the odd real bug.

The first one I ran into was to do with the 'PutBucketLogging' action; My real unit test case would work with no problem but as I transferred this real world unit test into canned test cases I got a fail on some of the composed XML.

The test parameters for the request where

New Perl project. Interactive Perl coding tasks to run in the browser

Some time ago I have created a small web project about Perl programming language. The site where you can execute Perl code online — PerlBanjo.com. (blog post about the release)

Today I'm happy to announce the new small project about Perl. This is the place with interactive coding tasks. You solve the task, enter the solution, system run it and tell you if it accept your submission. (PerlBanjo.com is used as a backend to run Perl code)

This is the link:

https://SquarePerl.com/en/problems

Now there are only several tasks. The source code for all the all tasks is hosted on GitHub, so anybody can propose a fix for the task or create the new task.

I start to write Mojolicious Startup

I start to write Mojolicious Startup. This is Japanese. Please use google translation.

Mojolicious Startup

Perl Weekly Challenge 45: Square Secret Code and Source Dumper

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

Task # 1: Square Secret Code

The square secret code mechanism first removes any space from the original message. Then it lays down the message in a row of 8 columns. The coded message is then obtained by reading down the columns going left to right.

For example, the message is “The quick brown fox jumps over the lazy dog”.

Then the message would be laid out as below:

thequick
brownfox
jumpsove
rthelazy
dog

The code message would be as below:

tbjrd hruto eomhg qwpe unsl ifoa covz kxey

#TPCiH to be @ Hilton Houston North Jun 23-27, 2020

The Hilton Houston North has been selected as the #TPCiH venue! #savethdates June 23-27, 2020. The 3-day tech conference goes from Wednesday, June 24 through Friday, June 26. Master-class tutorial sessions will be offered Tuesday, June 23 and Saturday, June 27 #perlcon #rakulang

Feedback sought

I've been trying to update the docs for Type::Tiny and want feedback. Is there anything that's hard to understand, or needs explaining more?

In particular, it's Type::Tiny::Manual and the other pod pages in that namespace that I'm working on.

Rewriting Legacy Code in Raku

I'm already working on Part II, but here's Part I in all its glory: http://www.theperlfisher.com/index.php/2019/11/24/rewriting-legacy-code-for-raku/ - I'm writing OLE::Storage_Lite from the original Perl 5 source, and this article series is my thoughts on the process so far.

Perl Weekly Challenge 44: Only 100, Please, and Make it $200

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

Challenge # 1: Only 100, Please

You are given a string “123456789”. Write a script that would insert ”+” or ”-” in between digits so that when you evaluate, the result should be 100.

Only 100, Please, in Perl

For solving this task, we first use a recursive combine subroutine that generates all possible strings by inserting between the digits of the “123456789” string the + plus addition, the - subtraction operator, or the '' empty string (i.e. no operator). We then use the evaluate subroutine with each string to perform the various arithmetic operations and compute whether the total is 100.

Perl Weekly Challenge 035: Binary Morse Code

The Encoder

Write a program to encode text into binary encoded Morse code.

Before we can encode Morse code into its binary representation, we need to encode normal text into Morse code. As a former Woodcraft member, I was able to write the following lines by heart:

my %to_morse = qw( a .-   b -... c -.-. d -..  e .    f ..-. g --.
                   h .... i ..   j .--- k -.-  l .-.. m --   n -.
                   o ---  p .--. q --.- r .-.  s ...  t -    u ..-
                   v ...- w .--  x -..- y -.-- z --.. );

The encoding subroutine is straightforward: split each word into separate characters, then replace each with the value from the above hash.

sub encode_to_morse {
    join '/', map $to_morse{$_} // "", split //, shift
}

Note that space is not present in the translation table, so it gets translated to an empty string, which creates the expected double slashes between words.

Paws XXIX (Would you like fries with that)

Well still in clean-up mode here in the Paws Pen trying to get the full t/10_response.t test case working.

I was having all sorts of fun with the 'GetBucketPolicy' action test. By fun I mean a good hour of frustration and cursing and gnashing of teeth as my real-time test script was working fine! I just could not get the test in 's3-get-bucket-policy.response.test.yml' to pass.

Then I stumbled on it.

This is the one very odd action on the AWS S3 API where it dose not return XML but returns JSON. Now I do handle this with this code


       } elsif (exists($headers->{'content-type'})
               and $headers->{'content-type'} eq 'application/json'
               and $ret_class->can('_payload')){
        $unserialized_struct->{$ret_class->_payload} = $content;

in RestXMLResponse.pm.

Perl Marketing Four Elements

Benefits

What benefits Perl provide to users?

Target

Who is the Perl user?

Strength

What are the strengths of Perl?

Place

Where do people find Perl?

These are the basic elements of Marketing.

Perl Weekly Challenge 43: Olympic Rings and Self-Descripting Numbers

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (January 19, 2020). 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: Olympic Rings

There are 5 rings in the Olympic Logo as shown below. They are color coded as in Blue, Black, Red, Yellow and Green.

olympic_rings-1.jpg

We have allocated some numbers to these rings as below: Blue: 8 Yellow: 7 Green: 5 Red: 9

The Black ring is empty currently. You are given the numbers 1, 2, 3, 4 and 6. Write a script to place these numbers in the rings so that the sum of numbers in each ring is exactly 11.

[ Perl | Raku | The ] Weekly Challenge - 2020

Here is my plan for 2020:

https://perlweeklychallenge.org/blog/plan-2020/

Platypus Next Generation

Platypus is getting an update. It’s not backward compatible, so you have to opt-in when you create the platypus instance. That makes it backward compatible for all the old code you may or may not have written. Please spread the word.

# old code:
use FFI::Platypus;
my $ffi = FFI::Platypus->new;

# new code:
use FFI::Platypus 1.00;
my $ffi = FFI::Platypus->new( api => 1 );

You should generally write all new code using the new API so that you can take advantage of the newer features and design fixes. You may want to also consider upgrading your existing code to use the new API for the same reasons.

Paws XXVII (Templated Paws)


Well today on paws I figured I would take a look and see what was outstanding in terms of code to fix. All that I could find was only really one thing and this boto fix well really a Kludge


/{Bucket}?action
/{Bucket}?action&id={Id}

where I add the id to the URI to get around a bug/problems when running this code on RestXmlCaller.pm;


$uri->query_form(%$qparams); 

would scramble the URI so the call would fail.

What I would like to do is roll back the changes I have made for Boto and see if I can find a pure Perl solution to my problem.

Perl Weekly Challenge 42: Octal Numbers and Balanced Parentheses

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (January 12, 2020). 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: Octal Number System

Write a script to print decimal number 0 to 50 in Octal Number System.

For example:

Decimal 0 = Octal 0
Decimal 1 = Octal 1
Decimal 2 = Octal 2
[ ... ]

For this task, I’ll start with Raku, because it is so easy in Raku.

Octal Number System in Raku

Raku has a base method to convert a number into a string representation in any base between 2 and 36.

Perl Weekly Challenge 034: Slices and a Dispatch Table

Slices

Write a program that demonstrates using hash slices and/or array slices.

In the spirit of TIMTOWTDI I decided to write a single program that demonstrates both the tasks at the same time.

Let’s start with slices. Slices are parts of structures (arrays and hashes). Slicing has a special syntax by which you tell Perl which indices or keys you want to use to obtain a slice.

For example, consider the following array:

my @keys = qw( not_this_one
               this_one
               this_one_too
               it_was_enough );

Naturally, we want to select the second and third one. We can use

$keys[1], $keys[2]

or

map $keys[$_], 1, 2;

but there’s a shorter and cleaner syntax for the same:

@keys[1, 2]

LedgerSMB 1.7.3 released

The LedgerSMB project aims to prevent small and mid-size businesses from getting locked-in by their accounting software vendor by providing free and open source accounting software, integrating invoicing, order processing, quotations and more (ERP). It's all Perl!

Having installed it myself, I found it very very fully featured. You can try out their demo and watch one of their numerous youtube intros and tutorials

The LedgerSMB development team has announced release 1.7.3.

This release contains the following fixes and improvements:

Changelog for 1.7.3

Releases for stable branches of 1.6.15 and 1.5.29 have also been released.

The project has an official Docker image, tar balls, and deb packages all detailed on their downloads page.

Paws XXX (Three of a kind)

Goodness Paws 30 and I am at least code compete as far as running through all of the different action found on S3. Now that leads me to a very important part.

I now have to do a little bit of back peddling and come up with a test suite for all the now fixed S3 actions. 90% of the bugs and fixes I have done so far on S3 have been for requests to the server not checking responses form the server.

Following on with this it makes sense that I test how things are sent to the server as well. I had a peek about in the test suite and except for a few of the basic actions there are no tests on request calls.

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.