Perl Weekly Challenge 238: Running Sum

These are some answers to the Week 238, 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 October 15, 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: Running Sum

You are given an array of integers.

Write a script to return the running sum of the given array. The running sum can be calculated as sum[i] = num[0] + num[1] + …. + num[i].

Example 1

Input: @int = (1, 2, 3, 4, 5)
Output: (1, 3, 6, 10, 15)

Example 2

Input: @int = (1, 1, 1, 1, 1)
Output: (1, 2, 3, 4, 5)

Example 3

Benchmarking Rakudo releases. Is Raku Still slow?

Benchmarking Rakudo releases. Is Raku Still slow?

Context

Around the first 'public' release of Perl 6 (The x-mas release) I wrote a module that uses the libgumbo from google to parse html5 webpages.

It was faster and more robust than the existing HTML::Parser module written in pure Perl 6. To be fair to the module, the full html5 norm is rather lenghtly to implement.

I was using this to parse my list of favorite fan fiction on fimfiction.net and try to make some stats around them. It was still not super fast, like 0.5+ sec to parse one page (I have like 20+ pages of favorites). So each run of the script was rather slow.

At the time Perl 6 was still in stabilization phase and performance improvements were not really important. But after a while, it started to creep its ways out into Moar and Rakudo. So I wanted to see the improvement over the Rakudo release for my Gumbo module.

Building all Rakudo release

Creating a Simple DSL in Perl

Let's look at the XSPF playlist format. It's a pretty simple XML-based file format.

  <?xml version="1.0" encoding="UTF-8"?>
  <playlist version="1" xmlns="http://xspf.org/ns/0/">
    <title>80's Music</title>
    <trackList>
      <track>
        <title>Take On Me</title>
        <creator>A-ha</creator>
        <location>https://example.com/music/01.mp3</location>
      </track>
      <track>
        <title>Tainted Love</title>
        <creator>Soft Cell</creator>
        <location>https://example.com/music/02.mp3</location>
      </track>
      <track>
        <title>Livin' on a Prayer</title>
        <creator>Bon Jovi</creator>
        <location>https://example.com/music/03.mp3</location>
      </track>
      </track>
    </trackList>
  </playlist>

The full specification has a lot more details, but for now, we'll just use those elements.

If we are building a Perl application that needs to allow less experienced users to write playlists in Perl, it might be useful to define a domain-specific dialect of Perl for writing playlists.

This week in PSC (092) | 2023-01-06

Having been off for two weeks, we spent a while just catching up with the state of the world. Not much of note to report this week.

  • We decided we should write up a list of “what’s expected in 5.38” to ensure we’re on track
  • We briefly chatted about :void, :scalar and :list as possible subroutine attributes for setting the return context

Perl Weekly Challenge 236: Exact Change

These are some answers to the Week 236, 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 October 1, 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: Exact Change

You are asked to sell juice each costs $5. You are given an array of bills. You can only sell ONE juice to each customer but make sure you return exact change back. You only have $5, $10 and $20 notes. You do not have any change in hand at first.

Write a script to find out if it is possible to sell to each customer with correct change.

Example 1

Hours left to donate to The Perl and Raku Foundation in the US 2022 tax yer

There are still a few hours left to donate to The Perl Foundation in the US 2022 tax year. Please support the great work the foundation does to support Perl and Raku

https://www.perlfoundation.org/donate.html

Marketing Committee Achievements in 2022

Looking back over 2022 the Marketing Committee presents our accomplishments to the Board and the Communities we serve.

Our sincere and abundant thanks to all those who have volunteered their time to deliver these outcomes.
  • Created the Prospectus for 2022
  • Arranged to have 2 Perl related articles published in the Linux Format magazine
  • Launched The Perl store offering Official Perl merchandise with profits going to the Perl Fund
  • Organized and held the Perl IDE Hackathon at The Perl and Raku Conference in Houston. This in response to community feedback about the importance of IDE support.
  • The Perl Foundation continues to grow on Facebook
  • Perl and Raku Conference page continues to grow on Facebook
  • Secured FOSDEM booth space in 2023
  • Secured the Camelia logo for The Perl and Raku Foundation

We are excited for the opportunities that the new year presents and express our continuing commitment to growing the Perl and Raku communities.

The committee exists to coordinate and facilitate volunteer efforts to promote the Perl and Raku ecosystems, create and distribute quality content, promote Perl and Raku related events, and assist with getting people involved.

All willing hands are welcome to attend our monthly meetings via Zoom. Please contact the committee via email for meeting invites.

Original post

PSA: Changing your b.p.o password is recommended

HTTPS support on blogs.perl.org, announced last month, has now undergone some additional small improvements to prevent the previously still theoretically possible exposure of session cookies in unencrypted requests.

As such, now is a good time to update your blogs.perl.org password to ensure you are not using credentials which may have previously been passively collected on an open network or the like.

Note: this recommendation is not a response to any known breach of blogs.perl.org. It is a response to the fact that security on blogs.perl.org has finally reached the level necessary to make this precautionary measure useful.

Perl Weekly Challenge 236: Array Loops

These are some answers to the Week 236, 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 October 1, 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: Array Loops

You are given an array of unique integers.

Write a script to determine how many loops are in the given array.

To determine a loop: Start at an index and take the number at array[index] and then proceed to that index and continue this until you end up at the starting index.

Example 1

SemVer but with Extra Steps

This is a variant of SemVer which mostly meets all its rules, except for releases prior to 0.2.0, where we bend them slightly.

It is my intention to use this versioning system for all open source software I develop from 1 January 2023 onwards. Existing open source projects I manage will adopt this scheme from their next release onwards. (Type::Tiny already somewhat does.)

Done before, Done better, Done again differently.

A Fool's Errand, and Quantum Theory

It is my firm belief that every thought or idea that you or I have, has been had before. On the balance of statistics, the chances are that those that had these ideas handled it better, and have developed more powerful utilities to exploit these innovations. One therefore has a few possible options, when thinking of creating a solution to a problem. The first probably is to look for other published solutions and use them; these may be more mature, tried, tested and optimised. The second is to go ahead and implement another idea, foolishly perceived as an innovation, leading to a proliferation of methods duplicating, triplicating existing work, in the end producing a half-baked distraction.

Moving from Perl_5.8.8 (2007) TO Perl_5.36.0 (2022)

Hi ! Everyone, here is a quick question.

As for the CGI script, the first line was

#! /usr/bin/perl -w

Is it not good enough to evoke PERL program at current Perl_5_36.0 (2022)??
If it is not good enough, let me know how should I write at the first line of CGI script???

Thanks !

Perl Weekly Challenge 235: Duplicate Zeros

These are some answers to the Week 235, 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 September 24, 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: Duplicate Zeros

You are given an array of integers.

Write a script to duplicate each occurrence of ZERO in the given array and shift the remaining to the right but make sure the size of array remain the same.

Example 1

Input: @ints = (1, 0, 2, 3, 0, 4, 5, 0)
Ouput: (1, 0, 0, 2, 3, 0, 0, 4)

Example 2

Input: @ints = (1, 2, 3)
Ouput: (1, 2, 3)

Example 3

Automatic Art

After the Harmonograph (which got in the meantime greatly extended), I got another tool for you to create art with - the Cellgraph:

GUIglobal.png

PerlayStation Games Console (Part 1)

Itchy fingers

A few reddit posts ago I saw an interesting article about maze generation and game written in Perl. Game development, I fully believe, is key to intellectual engagement, provides amusement to developers and non developers, and highlights the capabilities of a programming language. This led to an brief exploration of other Perl arcade/action games; Such games such as construdo and deliantra show how complex games can be created. Frozen Bubble is another addictive Perl classic. As a non-developer, I find these games only demonstrate the chasm between my lack of coding agility and the cleverness of others.

It's been done before

SDL and OpenGL seem like a way to go. A useful list of gaming libraries are provided by Debian Games Perl development packages and deliantra are examples of what can be achieved. Some interesting frameworks Quest3 are available although many with no recent updates e.g. this one.

TWC 195: Special Speedy Frequency

In which count only what we must.

In Raku, Perl, and C {via Perl's Inline::C} .

Perl Weekly Challenge 235: Remove One

These are some answers to the Week 235, 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 September 24, 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: Remove One

You are given an array of integers.

Write a script to find out if removing ONLY one integer makes it strictly increasing order.

Example 1

Input: @ints = (0, 2, 9, 4, 6)
Output: true

Removing ONLY 9 in the given array makes it strictly increasing order.

Example 2

Input: @ints = (5, 1, 3, 2)
Output: false

Example 3

Keeping Your Valuables Under Lock and Key

Consider the following fairly simple class, which creates a lookup object for month names:

I am jumping my Web pages from 2007 to 2022(now).

Hi Everyone, especially Web-Casting Programmers !!

Naturally I encountered various problems. When I moved from an old computer platform Compaq-Evo with Fedora Core 7 (2007 Red Hat LINUX) to a newer Ubuntu and Rocky 9.1 (2022) as Web-Casting, Web codes encounters various errors and weird displays on the screen. I have to fix all the problems one by one. O.K. let me start one question. Will you help me if you have similar experience. In my case this is a big jump from 2007 -> to 2022.

Here is my first question . HELP me !

When I tested PERL script at Rocky 9.1, I needed to have the command "perl" in front of excitable script filename.

[ At Fedora-Core 7 ] $ script.pl [ENTER] -> it runs. Of course, the file script.pl has an executable file permission.


[ At Rocky 9.1 ] $ script.pl [ENTER] -> It didn't run. But,
[ At Rocky 9.1 ] $ perl script.pl [ENTER] -> It runs.

Should I have to call the interpreter "perl" explicitly like the second line always ???
This is all the way my first posting at this blog, so I hope this posting will work to communicating with someone. Thank you !!

Perl fediverse network

ED: This is also posted on reddit, https://www.reddit.com/r/perl/comments/zp8d5g/perl_fediverseactivitypub_social_network/ so please check there also

A while back I bought the https://perl.social/ domain without much immediate use for it. I originally had it redirecting to the perl twitter community. However with the recent twitter drama going around I started setting up an activitypub based network to take the place of the twitter community in the advent that there was an exodus of Perl programmers from twitter. That seems to have been happening so I finally kicked into gear to get it ready for use.

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.