Handling Perl character codes is very easy even for beginners.

I feel that Perl users are losing confidence because of negative feedback from other communities.

The opinions of people who intend to harm Perl are 99% useless in my experience.

Handling character codes is actually simple.

Because all you have to do is remember the following three things.

1. use utf8 and save file as UTF-8

2. if you print text, encode text to platform charset(Linux is UTF-8, Windows is cp932)

3. if you get text from outside, decode text from platform charset(Linux is UTF-8, Windows is cp932)

If "use v7;" enabled "use utf8", it would be less memorable and less mistake.

Beginners will first remember that Perl source code is stored in UTF-8.

Next, the introductory person will notice that using a print statement results in a "Malformed ..." warning.

And, to get rid of the warning, he will have to encode with the platform character code.

Once he have learned that, he will naturally learn that he need to decode when he bring in text from the platform.

Perl Weekly Challenge 66: Divide Integers and Power Integers

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

Task 1: Divide Integers

You are given two integers $M and $N.

Write a script to divide the given two integers i.e. $M / $N without using multiplication, division and mod operator and return the floor of the result of the division.

Example 1:

Input: $M = 5, $N = 2
Output: 2

Example 2:

Input: $M = -5, $N = 2
Output: -3

Example 3:

Input: $M = -5, $N = -2
Output: 2

Monthly Report - June

COVID-19 seems to be still haunting us but life is getting back to normal slowly. I had the pleasure to attend the first "Conference in the Cloud". It was 3 days event. I booked 3 days off from the work so that I can focus on the event without any interruptions. It was my first experience attending event in the cloud. I found it hard to focus on the talk in general.

Could it be as I was at home with kids running around?

The day one itself started on a very happy note with the announcement of "Perl 7" by Sawyer X. The entire day one was dedicated to this very topic. brian d foy even had his first book "Preparing for Perl 7" launched with the announcement. Thanks to the author brian d foy, I had the pleasure to read the first copy of the book. I simply loved it. The best introductory book on Perl 7 so far. Please go and check out yourself.

CY's Post on PWC#064 - my shortcomings

This is a part of Perl Weekly Challenge(PWC) #064 and the followings are related to my solutions. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email)(before Monday GMT+0 00:00) if possible.

Task 1:

A runner has to run from the upper-left corner to the lower-right corner in a race. The stadium of this race is rectangular, and each square meter area has different level of difficulty (caused by sand, cement, grass, slope...). Our runner has to choose a path with the least difficulty to complete the race.

My description makes it look like something from a competitive programming problem. Maybe someone will discover sometimes I made sentimental names in the codes. (I was a long-distance runner in high school and university, by the way.)

The heart of my solution for this task is:

+1 "use v7;" in Perl 7

As one of Perl user, +1 "use v7;" in newer version of Perl.

The use v syntax is worth it.

use v5.14

This syntax is the history of Perl and is also a mechanism for maintaining backward compatibility with newer versions of Perl.

The reason this was not used is simply the small granularity.

I don't remember much about Perl, so I can't tell the difference between use v5.20 and use v5.30.

And because the warnings and utf8 aren't turn on, I couldn't find a meaning to actively use it.

use v7; is very easy to understand.

use v7;

Imagine an application user actively uses it instead of writing use strict, use warnings, use utf8;, use feature'say', ....

I also think that I use it aggressively in application code.

Perl Weekly Challenge 64: Minimum Sum Path and Word Break

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

Spoiler Alert: This weekly challenge deadline is due in a few hours . 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: Minimum Sum Path

Given an m × n matrix with non-negative integers, write a script to find a path from top left to bottom right which minimizes the sum of all numbers along its path. You can only move either down or right at any point in time.

Example

Input:

[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ]

The minimum sum path looks like this:

BLOG: The Weekly Challenge #066

https://perlweeklychallenge.org/blog/weekly-challenge-066

graphql-perl - plugin to make GraphQL "just work" with Mojo publish/subscribe functionality

GraphQL is the new, shiny way to do APIs. It minimises number of round-trips for clients to query what need. But what about real-time updates? How can we cut down the time needed for clients to get new information? Are we forcing them to constantly poll? That seems expensive and also slow.

GraphQL's official standard now includes "subscriptions". The obvious transport for that is WebSockets, and the de facto standard for that is Apollo GraphQL's subscriptions-transport-ws.

As of 0.16, Mojolicious::Plugin::GraphQL supports WebSockets, and GraphQL subscriptions, conforming to the Apollo protocol.

A well-known model for distributing information in an event-driven way is "publish/subscribe" (or "pub/sub"). To both demonstrate the subscription capability, and to provide useful functionality, there is now a new "convert plugin" for GraphQL with the two Mojo modules that implement pub/sub (with Redis and PostgreSQL): GraphQL::Plugin::Convert::MojoPubSub.

CY's Recent Submission for PWC(061-063)

This is a part of Perl Weekly Challenge(PWC) and the followings are related to my solution. If you want to challenge yourself on Perl, go to https://perlweeklychallenge.org, code the latest challenges, submit codes on-time (by GitHub or email)(before Monday GMT+0 00:00) if possible, before reading my blog post.

Miss out blogging for a while. Here just write some lines on the recent PWC coding experience.

Challenge 061

ch-1 :

Enumeration

ch-2 :

Before coding, I had thought it was a complicated task for regular expression. It turned out smoother.

I use a subroutine possible_octet to check whether a number can be a part of IPv4 octet.

Its content:

sub possible_octet {
    my $item = $_[0];
    if ($item =~ /^[0-9]$/ or $item =~ /^[1-9][0-9]$/ ) {
        return 1; }
    elsif ($item =~ /^[1-9][0-9][0-9]$/) {
        return  ( $item <= 255) ;
    }
    else {
        return 0;
    }
}

Perl Weekly Challenge 63: Last Word and Rotate String

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

Spoiler Alert: This weekly challenge deadline is due in a couple of days (June 7, 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.

Task 1: Last Word Matching a Regex

Define sub last_word($string, $regexp) that returns the last word matching $regexp found in the given string, or undef if the string does not contain a word matching $regexp.

For this challenge, a “word” is defined as any character sequence consisting of non-whitespace characters (\S) only. That means punctuation and other symbols are part of the word.

The $regexp is a regular expression. Take care that the regexp can only match individual words! See the Examples for one way this can break if you are not careful.

Examples:

BLOG: The Weekly Challenge #065

https://perlweeklychallenge.org/blog/weekly-challenge-065

Stack Overflow Developer Survey 2020

There's a lot in it and we could question some of the methodology, but here's some thoughts.

EZFPPD-WoAAv2Dq.jpeg

Perl developers are older (and there aren't that many of them) but salaries are excellent.

I would note that TIOBE didn't match up too closely with common usage but there's no silver lining.

Ruby is now in consistent decline, I have read people linking this to Twitter moving away from Ruby on Rails but can't cite that claim. My observation is that RoR seems to have gone out of fashion in favor of lightweight server frameworks and I would suggest that Kubernetes has sidelined Puppet, so organizations aren't bringing in Ruby via apps/frameworks they want to use.

New Arel like SQL Manager

Some months ago I started working in a system similar to ActiveRecord. But then it became pretty big so then I centered my attention in a SQL AST manager instead.

So I made a library that is basically an Arel port. You can see the README with most of the basic info. After looking at implementations in CPAN I realized there are many of them already but all of them based on hash structures.

This impl can instead represent a full SQL AST mainly using builder chainable methods.

I need some feedback on wether you think it will be something that is useful.

Thanks in advance.

Repo link: https://bitbucket.org/juankpro/perl-sql/src/master/

PD: Here is another question. If you try to download and use the lib right now it will not work because it depends on another library made by me as well: https://bitbucket.org/juankpro/model-support/admin

This library is a group of packages with somewhat unrelated utility functions that allows me to support my own perl OOP engine implementation shared through other libraries I'm working on. I don't know what's the best approach to handle this. Is it ok to upload this library separately? if I need to reuse this code again, how do I prevent collisions if my other libs will use it as well?

Prima: release v1.59 adds major text rendering functionality

  1. Previously it was only possible to output text with strings using text_out() method. Now, a more versatile and modern way is added with text_shape() method that converts text string in a series of glyphs, that allows the following:

    • Full unicode bidi processing
    • Support for font ligatures
    • Native support for right-to-left text
    • Transparent font substituion where a single font does not contain necessary glyphs

    In addition to that, infrastructure was added to support RTL and shaping in all standard Prima widgets. Run podview Prima::Drawable::Glyphs and check out the examples in the end of the document.

  2. PostScript backend rewritten to generate embedded Type1 fonts. This allows to generate unicode text in PostScript documents.

  3. In X11 backend, standard key combination (Ctrl+Shift+U) accepts unicode hex number as a character input. Try typing "a" then Ctrl+Shift+U 300 ENTER.

  4. Prima::*Dialog packages are moved to Prima::Dialog::* namespace

glyphs.png

BLOG: The Weekly Challenge #064

https://perlweeklychallenge.org/blog/weekly-challenge-064

Dancer2 0.300004 Released

The Dancer Core Team would like to announce the availability of Dancer2 0.300004. This release brings several important fixes and enhancements:

  • Session cookies can be restricted to a first-party or same-site context

  • There were a number of spots where Dancer2 would return a 500 error upon receiving an invalid request, rather than (correctly) returning 400 - Bad Request. Many, if not all, of these have been fixed.

For more information about same-site context, please refer to [RFC-6265bis]( https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site).

To use this, add the cookie_same_site key to your session engine configuration in the appropriate YAML file. Valid settings include Strict, Lax, and None.

The complete changelog is as follows: 0.300004 2020-05-26 20:52:34-04:00 America/New_York

Late May Software Releases

There have been several! LANraragi, ZEVENET CE, LedgerSMB, and Sympa. All great perl software!

LANraragi v.0.7.0 -- Cat People (Putting Out Fire)

Web application for archival and reading of manga/doujinshi. Lightweight and Docker-ready for NAS/servers.

This release includes an API revamp, categories have finally been added, PDF files are now first class citizens, Docker image is much smaller, and many other fixes and small features.

Check it out here: https://github.com/Difegue/LANraragi/releases/tag/v.0.7.0


ZEVENET Community Edition v5.11.1

The community edition of this load balancer appliance is bugfixes.

Check it out at: https://github.com/zevenet/zlb/releases/tag/v5.11.1


LedgerSMB 1.7.14

This accounting software's release is composed primarily of bugfixes.

Check it out at: https://github.com/ledgersmb/LedgerSMB/releases/tag/1.7.14

Sympa 6.2.56

This release is a all bugfixes for this mailing list management software

Check it out at: https://github.com/sympa-community/sympa/blob/6.2.56/NEWS.md

Perl Weekly Challenge 061: Product SubArray And IPv4 Partition

Product SubArray

Given a list of 4 or more numbers, write a script to find the contiguous sublist that has the maximum product. The length of the sublist is irrelevant; your job is to maximize the product.

Example

Input: [ 2, 5, -1, 3 ]

Output: [ 2, 5 ] which gives maximum product 10.

The easiest (but probably not the fastest) method would be to start from each position and compute the products of all the possible sublists starting at the position, remembering the positions where the product is maximal.

I automatically reached for List::Util’s product to get the products easily, but alas! Running

product(-1, 3)

caused a Floating point exception (bug reported). So, I had to implement product myself:

BLOG: The Weekly Challenge #063

https://perlweeklychallenge.org/blog/weekly-challenge-063

Perl Weekly Challenge 62: Sort Email Addresses

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

Task 1: Sort Email Addresses

Write a script that takes a list of email addresses (one per line) and sorts them first by the domain part of the email address, and then by the part to the left of the @ (known as the mailbox).

Note that the domain is case-insensitive, while the mailbox part is case sensitive. (Some email providers choose to ignore case, but that’s another matter entirely.)

If your script is invoked with arguments, it should treat them as file names and read them in order, otherwise your script should read email addresses from standard input.

Bonus

Add a -u option which only includes unique email addresses in the output, just like sort -u.

Example:

If given the following list:

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a design donated by Six Apart, Ltd.