course change for Kephra

Kephra, an editor for programming (mostly Perl) written in WxPerl is my main project since I stumbled into the Perl community. Most people I know already heard of it - but I want to write about a new development that might be helpful for some, which might consider to use it even if it has a very limited feature set (forth rewrite baby!).

Perl Weekly Challenge 226: Shuffle String

These are some answers to the Week 226, Task 1, 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 July 23, 2023 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: Shuffle String

You are given a string and an array of indices of same length as string.

Write a script to return the string after re-arranging the indices in the correct order.

Example 1

Input: $string = 'lacelengh', @indices = (3,2,0,5,4,8,6,7,1)
Output: 'challenge'

Example 2

Input: $string = 'rulepark', @indices = (4,7,3,1,0,5,2,6)
Output: 'perlraku'

My Perl Weekly Challenge

Really, how hard could it be?

All this talk about types, objects, and systems, got me to thinking, "what would it take to create a 100% backwards-compatible pure Perl proof-of-concept for optionally typable subroutine signatures". I mean really, how hard could it be? So I started sketching out some ideas and here's what I came up with:

use typing;

sub greet :Function(string, number) :Return() {
  my ($name, $count) = &_;

  print "Hi $name, you have $count messages waiting ...\n";
}

Class::Plain - Class Syntax for Hash-Based Perl OO

Class::Plain provides a class syntax for the hash-based Perl OO.

Usage

Casting Perls before Splines

As I sit pondering my peas at the dinner table, my thoughts are unnaturally drawn to the similarity between these pulses and Perl. A famous poet once said that "For a hungry man, green peas are more shiny than gleaming pearls". From these green orbs on my plate, the mind drifts to a recent virtual conversation regarding logos, branding, rebirth and innovation in Perl. One wonders whether such heated debates are important, relevant and what it might mean for Perl in the future. The Camel (from the O'Reilly Book on Perl) has long been the image associated with the language, along with the Onion (Origin perhaps from Larry Walls' "state of the onion" presentation). Personally it is not something that I feel passionately about. "Perl, with any other logo would be just as quirky" as Will Shakespeare is reported to have said. But The Camel is the popular, recognisable standard "logo" with some, as yet to be tested, copyright and trademark "issues"

Perl Weekly Challenge 225: Left Right Sum Diff

These are some answers to the Week 225, Task 2, 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 July 16, 2023 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 2: Left Right Sum Diff

You are given an array of integers, @ints.

Write a script to return left right sum diff array as shown below:

London Perl Workshop: Status Update & 2023

Hello all. It's been a while. As you may have guessed there will not be a workshop this year. We spoke about organising one but the uncertainty around restrictions, along with other organisational constraints, resulted in our decision not to.

Types, Objects, and Systems, Oh my!

Inextricably bound

Perl isn't a strongly typed language, and its built-in types are limited and not generally accessible to the engineer, however, Perl supports various classes of data and in recent years has flirted with various ways of enabling runtime type checking.

In a strongly typed language the tl;dr; case for declaring data types is memory management, compile-time code optimization, and correctness. To this day I'm both impressed and horrified by the number of errors caught when I implement some kind of type checking in my programs. When it comes to runtime type checking we're only concerned with enforcing correctness.

Types, values, objects, signatures, and the systems that tie these all together, are all inextricably bound. They are necessarily interdependent in order to present/provide a cohesive and consistent system. Peeling back the layers a bit, types are merely classifications of data. Any given piece of data can be classified as belonging to a particular type whether implicit or explicit.

Type::Tiny v2 is Coming

Eagle-eyed watchers of CPAN may have noticed that I've recently been releasing Type::Tiny development releases with version numbers 1.999_XYZ.

Type::Tiny v2 is intended to be compatible with Type::Tiny v1. If you've used Type::Tiny v1, you shouldn't need to change any code, but Type::Tiny v2 has a few new features which may make your code simpler, more maintainable, and more readable if you adopt them.

Perl Weekly Challenge 225: Max Words

These are some answers to the Week 225, Task 1, 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 July 16, 2023 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: Max Words

You are given a list of sentences, @list.

A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

Write a script to find out the maximum number of words that appear in a single sentence.

Example 1

Input: @list = ("Perl and Raku belong to the same family.",
                "I love Perl.",
                "The Perl and Raku Conference.")
Output: 8

Example 2

Hacktoberfest 2022 is near!

Hello Fellow Perl mongers!

Every year in the month of October a company named DigitalOcean hosts an event named Hacktoberfest.

If you ever wanted to contribute to a Perl project now is a good time to give it a go!. Here are a few beginner friendly projects that are up-for-grabs and here is a list of Github projects with the "hacktoberfest' topic.

If you are a project owner and would like someone to participate in your project make sure to add the 'hacktoberfest" topic to a github/gitlab issue and promote your project on ( blogs.perl.org, perl.com/ ,Perlweekly, Perl Reddit , Medium ) or any other channels used to promote your Perl content.

Looking forward to seeing your Hacktoberfest pull requests!

An artistic tool for programmers.

I just release App::GUI::Harmonograph for your leisure and pleasure. In case your not not an English noble man form the 18th century who could afford an Harmonograph, even though modern DIY kits are quite affordable, it is a set of set of 3 independent pendula, which move a pen and and paper to create harmonious drawings, of sometimes extraordinary elegance and richness. I got the impulse and knowledge of the apparatus from this book and refer for more background details to this publication. However, the documentation (which is also displayed by the program itself) is much more of practical use, because the WxPerl version is greatly enhanced in possibilities, not in the least for dotted lines with variable density an additional rotation movement and flowing colors.

How does SPVM resolve the problems of Perl numeric operations?

How does SPVM resolve the problems of Perl numeric operations?

I hear Perl have the problems of numeric operation.

I realized this problems, and try to resolve them using SPVM. (SPVM is yet experimental release).

What is SPVM?

SPVM is a programing language to provide fast static-typed numeric operation and array operations into Perl.

I'm writing SPVM Language Specification now.

Do you want to use static typed numeric arrays(byte[], short[], int[], long[], float[], double[]) in Perl? You can write these using SPVM.

Perl Weekly Challenge 224: Special Notes

These are some answers to the Week 224, Task 1, 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 July 9, 2023, 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: Special Notes

You are given two strings, $source and $target.

Write a script to find out if using the characters (only once) from source, a target string can be created.

Example 1

Input: $source = "abc"
       $target = "xyz"
Output: false

Example 2

Input: $source = "scriptinglanguage"
       $target = "perl"
Output: true

Example 3

Saving Perl packages through local

In Perl there is an expression local . It substitutes the specified value with undef until the end of the block. The values can be global hashes, arrays and scalars, as well as elements or slices of hashes and scalars. The problem is that package hashes are not saved by local. By package hashes I mean a hash with a colon at the end (%Package::) which stores the package symbols (GLOB).

Death: A Terminal Experience

A program being executed, self terminating on encountering an non-viable condition is a typical scenario in Perl programs. The death sentence can deliver information about the departed application to the user as justification and demand appropriate resolution for the subsequent reincarnation.

Now I know my code fails more often than it succeeds, and it is for this reason I am planning an alternative wake for the programmed parting of my future terminal applications. As a once-in-a-run-time event, death might be more elaborately delivered, something to be celebrated. The last words of a dying application softens the developers ensuing grief, while encouraging resuscitation with an appropriately delivered injection of code.

Imagine my code being transformed from:-

do_something_risky() or die "you evil monster $!";

into

get_away_with_it() or deathSentence($!) 

producing something like this on the terminal:-

death.png

I know such distraction wastes time, there are probably many more error trapping and diagnostic tools available. These may be absorbed over time...I am not really an expert. But I am collecting a series of reasonably uncontroversial, hopefully humorous "epitaphs"...

On interpolating stuff into pattern matches

Tom Wyant:

Interestingly (to me, at least) they reported that the removal of the /o modifier made their case 2-3 times slower. This surprised me somewhat, as I had understood that modern Perls (for some value of "modern") had done things to minimize the performance difference between the presence and absence of /o.

They indeed have.

Ironically, it’s qr objects which don’t get that benefit. On the machine I’m typing on, the following benchmark…

Perl Weekly Challenge 223: Box Coins

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

Task 2: Box Coins

You are given an array representing box coins, @box.

Write a script to collect the maximum coins until you took out all boxes. If we pick box[i] then we collect the coins $box[i-1] * $box[i] * $box[i+1]. If $box[i+1] or $box[i-1] is out of bound then treat it as 1 coin.

Example 1:

Input: @box = (3, 1, 5, 8)
Output: 167

Step 1: pick box [i=1] and collected coins 3 * 1 * 5 => 15.  Boxes available (3, 5, 8).
Step 2: pick box [i=1] and collected coins 3 * 5 * 8 => 120. Boxes available (3, 8).
Step 3: pick box [i=0] and collected coins 1 * 3 * 8 => 24.  Boxes available (8).
Step 4: pick box [i=0] and collected coins 1 * 8 * 1 => 8.   No more box available.

Example 2:

The progress of the new class feature of Perl

I introduce the progress of the new class feature of Perl. If you are interested in the progress of the new class feature of Perl, please see the following topics.

p5p Mailing List

Pre-PR Preview of `use feature 'class'`

Trial of the implementation

leonerd/perl5/feature-class | Github

Specification

Corinna RFC

In the current spec, the new class syntax is the following codes.

Match Anything, Quickly -- Revision 1

O wad some Power the giftie gie us
To see oursels as ithers see us!
It wad frae mony a blunder free us,
An' foolish notion: ...

My previous blog post, Match Anything, Quickly, brought a number of responses which are worth reading in their own right. The one that triggered this post, though, was from Nerdvana and Devin of Cincinnati Perl Mongers, who pointed out an error in my benchmark script. I had left off the intended /smx from the qr/ ... / version of the test, which meant that the regular expression did not in fact match.

Three cheers for code reviews!

The Cincinnati Perl Mongers came up with a further case which combines my two:

eval "do { my \$regex = qr/ $re /smx; " .
        "sub { \$MATCH =~ /\$regex/o }};"

They benchmarked this as being slightly slower than the case where the regular expression is simply interpolated into the subroutine verbatim.

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.