handy.h: Fix off-by-1 error in comment

Perl commits on GitHub

Published by khwilliamson on Wednesday 20 November 2024 18:02

handy.h: Fix off-by-1 error in comment

Update CoreList

Perl commits on GitHub

Published by thibaultduponchelle on Wednesday 20 November 2024 12:40

Update CoreList

Module::CoreList is released on CPAN

Perl commits on GitHub

Published by thibaultduponchelle on Wednesday 20 November 2024 12:35

Module::CoreList is released on CPAN

LPW 2024: Max Maischein (Corion) - Managing recent files from Perl

r/perl

Published by /u/briandfoy on Wednesday 20 November 2024 12:31

Also update VERSION of dist/Module-CoreList/lib/Module/CoreList/Utils.pm

Perl commits on GitHub

Published by thibaultduponchelle on Wednesday 20 November 2024 10:05

Also update VERSION of dist/Module-CoreList/lib/Module/CoreList/Utils.pm

Prepare Module::Corelist for 5.41.7

Perl commits on GitHub

Published by thibaultduponchelle on Wednesday 20 November 2024 09:48

Prepare Module::Corelist for 5.41.7

In a program I'm using a rather sophisticated parameter for CGI's start_html, but that results in a duplicate rel attribute for the CSS passed via -style.

Example code:

#!/usr/bin/perl
use strict;
use warnings;
use CGI;

my $attr = {
    '-script' => [
        {
            '-src' => 'https://server.domain.org/app/js/0.js',
            '-type' => 'text/javascript'
        },
        {
            '-src' => 'https://server.domain.org/app/js/2.js',
            '-type' => 'text/javascript'
        },
        {
            '-type' => 'text/javascript',
            '-src' => 'https://server.domain.org/app/js/3.js'
        }
    ],
    '-noscript' => '<link type="text/css" href="https://server.domain.org/app/style/3.css" id="3.css" title="No Script Additions" rel="stylesheet" />',
    '-encoding' => 'utf-8',
    '-author' => 'Me &lt;my@e.mail&gt;',
    '-lang' => 'de-DE',
    '-style' => [
        {
            '-id' => '2.css',
            '-type' => 'text/css',
            '-src' => 'https://server.domain.org/app/style/2.css',
            '-rel' => 'stylesheet alternate',
            '-title' => 'JavaScript Additions'
        }
    ],
    '-meta' => {
            'copyright' => 'Copyright ...',
            'keywords' => 'bla',
            'description' => 'Application to ...'
    },
    '-title' => '[ldapdir-3.8] Login'
};
my $query = CGI->new;

print $query->start_html($attr), "\n";

Output:

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de-DE" xml:lang="de-DE">
<head>
<title>[ldapdir-3.8] Login</title>
<link rev="made" href="mailto:Me%20%26lt%3Bmy%40e.mail%26gt%3B" />
<meta name="copyright" content="Copyright ..." />
<meta name="description" content="Application to ..." />
<meta name="keywords" content="bla" />
<link rel="stylesheet" type="text/css" href="https://server.domain.org/app/style/2.css" id="2.css" rel="stylesheet alternate" title="JavaScript Additions"/>
<script src="https://server.domain.org/app/js/0.js" type="text/javascript"></script>
<script src="https://server.domain.org/app/js/2.js" type="text/javascript"></script>
<script src="https://server.domain.org/app/js/3.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<noscript>
<link type="text/css" href="https://server.domain.org/app/style/3.css" id="3.css" title="No Script Additions" rel="stylesheet" />
</noscript>

</head>
<body>

I tend to believe it's a bug in $CGI::VERSION='3.63'. How can I fix it?

List of new CPAN distributions – Oct 2024

Perlancar

Published by perlancar on Wednesday 20 November 2024 04:13

dist author abstract date
Alien-fpm NHUBBARD Alien package for the fpm package builder 2024-10-20T14:38:39
App-Greple-stripe UTASHIRO Greple zebra stripe module 2024-10-07T08:06:15
App-Greple-under UTASHIRO greple under-line module 2024-10-14T09:17:05
App-LinkSite DAVECROSS 2024-10-29T11:43:59
App-Tarotplane SAMYOUNG Curses flashcard program 2024-10-31T18:18:37
App-findsort PERLANCAR Unix find wrapper to add sorting 2024-10-27T00:05:59
App-mqtt2job CHRISC Subscribe to an MQTT topic and trigger job execution 2024-10-24T22:22:49
App-sbozyp NHUBBARD a package manager for Slackware's SlackBuilds.org 2024-10-20T20:41:27
Business-PAYONE ARTHAS Perl library for PAYONE online payment system 2024-10-17T09:59:35
Cache-Memcached-PDeque HAIJENP Implements a priority deque using memcached as storage 2024-10-25T23:24:58
Catalyst-View-EmbeddedPerl-PerRequest-ValiantRole JJNAPIORK Role to add Valiant HTML Formbuilder support 2024-10-03T21:32:43
Comparer-file_mtime PERLANCAR Compare file's mtime (modification time) 2024-10-06T00:05:31
Crate CARELINE Everything that PDK modules needs 2024-10-05T12:14:57
DBIx-Class-ResultSet-PrettyPrint PTC Pretty print DBIx::Class result sets. 2024-10-14T12:10:32
DBIx-HoldMyPlace LANX Automagic SQL Placeholders from interpolated variables 2024-10-24T17:09:34
DBIx-QuickORM EXODIST Actively maintained Object Relational Mapping that makes getting started Quick and has a rich feature set. 2024-10-26T07:48:12
Date-Business BPSCHUCK fast calendar and business date calculations 2024-10-09T01:15:25
DateTime-Format-Intl JDEGUEST A Web Intl.DateTimeFormat Class Implementation 2024-10-09T02:07:15
Debug-Helper-Flag AAHAZRED Define and import boolean constant DEBUG_FLAG helping to optimize code. 2024-10-10T07:48:38
Device-Chip-From-Sensirion PEVANS a collection of chip drivers for Sensirion sensors 2024-10-23T11:08:42
Dist-Zilla-App-Command-DiffMint HAARG Compare files to what a minting profile produces 2024-10-15T08:56:46
Dist-Zilla-Plugin-SimpleBootstrap HAARG Bootstrap a Dist::Zilla library 2024-10-04T23:31:37
Dist-Zilla-Plugin-Test-Pod-Coverage-TrustMe HAARG An author test for Pod Coverage 2024-10-09T04:35:48
File-Information LION generic module for extrating information from filesystems 2024-10-11T03:10:43
File-SharedVar CDRAKE Pure-Perl extension to share variables between Perl processes using files and file locking for their transport 2024-10-17T12:03:33
File-Strfile SAMYOUNG OO strfile interface 2024-10-30T16:27:36
File-ValueFile LION module for reading and writing ValueFile files 2024-10-03T00:30:39
Frame CRABAPP Bare-bones, real-time web framework (WIP) 2024-10-05T23:42:01
Geo-Coder-GeoApify NHORNE Provides a Geo-Coding functionality using https://www.geoapify.com/maps-api/ 2024-10-23T17:12:59
Kelp-Module-Storage-Abstract BRTASTIC Abstract file storage for Kelp 2024-10-16T20:04:19
List-Stream RAWLEYFOW Simple, fast, functional processing of list data 2024-10-07T15:49:41
Locale-Intl JDEGUEST A Web Intl.Locale Class Implementation 2024-10-07T05:24:54
MPGA NNZ MPGA – a module that makes it easy to write PERL programs 2024-10-05T14:26:55
Math-LiveStats CDRAKE Pure perl module to make mean, standard deviation, and p-values available for given window sizes in streaming data 2024-10-11T04:34:55
Minima TESSARIN Efficient web framework built with modern core classes 2024-10-04T21:57:09
Net-RDAP-Server GBROWN an RDAP server framework. 2024-10-22T15:56:38
PDK-Concern CARELINE PDK::Concern::H3c::Netdisco – Explore and manage LLDP topology for H3C devices 2024-10-17T13:32:50
PDK-Content CARELINE Content parsing and management for PDK 2024-10-06T13:51:02
PDK-Crate CARELINE Everything that PDK modules needs 2024-10-05T12:19:02
PDK-DBI CARELINE PDK::DBI- A Moose-based wrapper for MySQL|Postgresql database operations using DBIx::Custom 2024-10-10T03:28:18
PDK-Utils CARELINE Utility functions for PDK 2024-10-07T06:42:24
Plack-App-Storage-Abstract BRTASTIC Serve files with Storage::Abstract 2024-10-13T20:10:13
Quaint LNATION The great new Quaint! 2024-10-27T12:51:58
Rex-Commands-PerlSync BRTASTIC Sync directories, better 2024-10-01T18:26:54
SPVM-IO-Socket-SSL KIMOTO Sockets for SSL. 2024-10-28T02:23:49
SPVM-Net-DNS-Native KIMOTO Short Description 2024-10-21T07:04:37
SQL-Formatter PLICEASE Format SQL using the rust sqlformat library 2024-10-05T00:09:29
Slackware-SBoKeeper SAMYOUNG SlackBuild package manager helper 2024-10-31T22:09:33
SortKey-Num-file_mtime PERLANCAR File modification time as sort key 2024-10-13T00:05:46
Sorter-file_by_mtime PERLANCAR Sort files by mtime (modification time) 2024-10-20T00:06:08
Storage-Abstract BRTASTIC Abstraction for file storage 2024-10-13T14:20:10
Syntax-Keyword-Assert PEVANS debugging checks that throw exceptions 2024-10-01T14:24:23
Syntax-Keyword-PhaserExpression PEVANS phasers as arbitrary expressions rather than blocks 2024-10-28T21:33:23
Sys-Ebpf TAKEMIO Pure-Perl interface for eBPF (extended Berkeley Packet Filter) 2024-10-04T10:02:24
Test2-Plugin-DBBreak JOSERIJO Automatic breakpoint on failing tests for the perl debugger 2024-10-23T12:08:14
Weather-API-Base DKECHAG Base/util module for Weather API clients 2024-10-30T23:56:19
Weather-OWM DKECHAG Perl client for the OpenWeatherMap (OWM) API 2024-10-06T19:54:59
XTP DYLIBSO XTP Perl SDK 2024-10-30T23:18:31
Xerarch LNATION The great new Xerarch! 2024-10-09T19:27:16

Stats

Number of new CPAN distributions this period: 59

Number of authors releasing new CPAN distributions this period: 34

Authors by number of new CPAN distributions this period:

No Author Distributions
1 CARELINE 6
2 PERLANCAR 4
3 BRTASTIC 4
4 HAARG 3
5 SAMYOUNG 3
6 PEVANS 3
7 LNATION 2
8 JDEGUEST 2
9 DKECHAG 2
10 KIMOTO 2
11 NHUBBARD 2
12 CDRAKE 2
13 LION 2
14 UTASHIRO 2
15 EXODIST 1
16 TESSARIN 1
17 DYLIBSO 1
18 HAIJENP 1
19 JJNAPIORK 1
20 TAKEMIO 1
21 DAVECROSS 1
22 NNZ 1
23 LANX 1
24 RAWLEYFOW 1
25 JOSERIJO 1
26 CHRISC 1
27 AAHAZRED 1
28 CRABAPP 1
29 GBROWN 1
30 PLICEASE 1
31 NHORNE 1
32 BPSCHUCK 1
33 ARTHAS 1
34 PTC 1

List of new CPAN distributions – Sep 2024

Perlancar

Published by perlancar on Wednesday 20 November 2024 04:13

dist author abstract date
Acme-App-Broken CONTRA The great new Acme::App::Broken! 2024-09-05T12:41:54
Acme-Both-MakefilePL-And-BuildPL CONTRA The great new Acme::Both::MakefilePL::And::BuildPL! 2024-09-23T17:37:52
Acme-CPANModules-UnixCommandImplementations PERLANCAR List of various CLIs that try to reimplement traditional Unix commands 2024-09-08T00:05:29
Acme-CPANModules-UnixCommandWrappers PERLANCAR List of various CLIs that wrap existing Unix commands 2024-09-01T00:05:58
Acme-Free-API-Geodata-GeoIP CAVAC Lookup GeoIP data for an IP address 2024-09-01T10:12:01
Acme-Free-Advice SANKO Wise words. Dumb code. 2024-09-03T17:56:37
Acme-Free-Advice-Slip SANKO Seek Advice from the Advice Slip API 2024-09-03T16:56:16
Acme-Free-Advice-Unsolicited SANKO Solicit Unsolicited Advice from the Unsolicited Advice API 2024-09-03T16:59:12
Acme-Free-Dog-API OODLER Perl API client for the Dog API service, https://dog.ceo/dog-api. 2024-09-04T05:43:45
Acme-Free-Public-APIs OODLER Perl API client for … 2024-09-07T01:03:15
Acme-Insult SANKO Code That Wasn't Raised Right 2024-09-03T16:02:55
Acme-Insult-Evil SANKO Programmatically Generate Evil Insults 2024-09-03T15:20:59
Acme-Insult-Glax SANKO Programmatically Generate Insults 2024-09-03T15:19:30
Acme-Insult-Pirate SANKO Programmatically Generate Pirate Themed Insults 2024-09-03T15:24:06
Alien-libsecp256k1 BRTASTIC Interface to libsecp256k1 2024-09-12T15:25:26
Alt-Crypt-OpenSSL-PKCS12-Broadbean DAKKAR Perl extension to OpenSSL's PKCS12 API. 2024-09-30T09:02:44
App-DesktopNotifyUtils PERLANCAR Utilities related to Desktop::Notify 2024-09-16T00:05:20
App-HeightUtils PERLANCAR Utilities related to body height 2024-09-15T00:06:02
App-MediaPi MATHIAS Media Player for Raspberry Pi or other devices with very small screen. 2024-09-04T21:26:50
App-TimeTracker-Gtk3StatusIcon DOMM Show TimeTracker status as a GTK3 StatusIcon in the system tray 2024-09-11T19:36:29
App-cpx CONTRA Install and execute CPAN package binaries 2024-09-05T17:09:44
App-optex-glob UTASHIRO optex filter to glob filenames 2024-09-10T12:36:16
App-optex-scroll UTASHIRO optex scroll region module 2024-09-11T12:40:16
App-pdfresize PERLANCAR Resize each page of PDF file to a new dimension 2024-09-29T00:06:10
App-pdfsize PERLANCAR Show dimensions of PDF files 2024-09-22T00:05:31
Arcus-Client JAMTWOIN Perl client for arcus cache cluster 2024-09-04T02:56:17
Ascii-Text-Image LNATION module for generating images using ASCII text. 2024-09-04T15:30:30
Bio-EnsEMBL ABECKER Bio::EnsEMBL – Ensembl Core API 2024-09-03T10:23:40
Bitcoin-Secp256k1 BRTASTIC Perl interface to libsecp256k1 2024-09-17T22:11:45
CLI-Meta-less PERLANCAR Metadata for 'cp' Unix commnd 2024-09-27T08:41:45
Catalyst-View-EmbeddedPerl JJNAPIORK Catalyst View wrapper for Template::EmbeddedPerl 2024-09-25T22:17:09
Catalyst-View-EmbeddedPerl-PerRequest JJNAPIORK Catalyst View wrapper for Template::EmbeddedPerl 2024-09-25T23:20:52
Circle-Node CHENGYU The great new Circle::Node! 2024-09-09T13:37:01
Config-IniFiles-Check-Health HORSHACK 2024-09-09T13:06:48
DBIx-Class-Helper-ColumnNames RRWO Retrieve column names from a resultset 2024-09-23T22:20:45
Daje-Generate JANESKIL lib::Generate 2024-09-22T15:46:05
Data-Identifier LION format independent identifier object 2024-09-18T14:36:10
Data-InfoBox SKIM Data objects for info box. 2024-09-15T11:37:07
Data-TagDB LION Work with Tag databases 2024-09-10T15:25:24
Date-Holidays-Adapter-USExtended GENE Adapter for the USExtended module holidays 2024-09-23T22:23:33
Date-Holidays-USExtended GENE Provides an extended set of United States holidays 2024-09-23T22:23:44
DateTime-Format-Unicode JDEGUEST Unicode CLDR Formatter for DateTime 2024-09-10T10:06:43
Devel-Cover-Report-Codecov-Service-GithubActions TOBYINK gather env vars from Github Actions for Codecov report 2024-09-06T07:41:09
Dist-Build-XS-PkgConfig LEONT Dist::Build extension to use pkg-config. 2024-09-13T20:11:49
Fred-Fish-DBUG CLEACH Perl implementation of the Fred Fish C/C++ macros for Perl. 2024-09-25T18:58:19
Full TEAM common pragmata for Perl scripts and modules 2024-09-14T01:53:27
Generate JANESKIL lib::GenerateSQL 2024-09-22T09:42:48
Getopt-Lazier JOJESSF Lazy Getopt-like BS 2024-09-02T15:31:38
Google-Protobuf-Loader MATHIAS Automatically load .proto file using the standard "use" syntax. 2024-09-22T20:40:43
Map-Metro-Plugin-Map-London ETJ Map::Metro map for London 2024-09-02T10:23:10
Math-Symbolic-Custom-Collect MJOHNSON Collect up Math::Symbolic expressions 2024-09-27T09:17:04
Math-Symbolic-Custom-ToShorterString MJOHNSON Shorter string representations of Math::Symbolic trees 2024-09-16T19:09:06
Mojolicious-Plugin-BModel BCDE Catalyst-like models in Mojolicious 2024-09-16T17:46:31
Mojolicious-Plugin-Badge GDT Badge Plugin for Mojolicious 2024-09-19T21:29:36
MooseX-Types-StrictScalarTypes DCANTRELL strict Moose type constraints for integers, numbers, and Booleans 2024-09-01T10:27:38
Net-LineNotify SHINGO A simple wrapper for LINE Notify API 2024-09-29T10:48:48
Net-SNMP-Mixin-PoE GAISSMAI mixin class for power over ethernet related infos from 2024-09-10T21:05:54
OSLV-Monitor VVELOX OS level virtualization monitoring extend for LibreNMS. 2024-09-10T21:09:59
Object-Pad-LexicalMethods PEVANS operator for lexical method call syntax 2024-09-20T19:02:48
PDL-Graphics-IIS ETJ Display PDL images on IIS devices (saoimage/ximtool) 2024-09-30T06:20:14
PDL-Minuit ETJ Minuit 1 optimization routines for PDL 2024-09-30T12:57:29
Sumu-Perl-Modules CEEJAY Perl Modules 2024-09-28T16:29:04
Sys-Async-Virt EHUELS LibVirt protocol implementation for clients 2024-09-15T20:23:53
Template-EmbeddedPerl JJNAPIORK Validation Library and more 2024-09-13T22:16:50
WebService-Hydra DERIV 2024-09-30T03:56:43
WebService-Xential WATERKIP A Xential REST API module 2024-09-18T01:25:55
Webservice-CVEDB-API HAX Fast Vulnerability lookups using CVE_ID and CPE23 2024-09-15T22:49:58
Webservice-InternetDB-API HAX Fast IP Lookups for Open Ports and Vulnerabilities using InternetDB API 2024-09-08T20:11:16
Webservice-Ipify-API HAX Lookup your IP address using Ipify.org 2024-09-08T21:44:08
Webservice-KeyVal-API OODLER Perl API client for the REPLACE API service, https://keyval.org/. 2024-09-23T19:21:15
Webservice-Purgomalum-API HAX Filter and removes profanity and unwanted text from input using PurgoMalum.com's free API 2024-09-20T22:41:00
Zleep LNATION zleep 2024-09-07T06:11:28

Stats

Number of new CPAN distributions this period: 72

Number of authors releasing new CPAN distributions this period: 41

Authors by number of new CPAN distributions this period:

No Author Distributions
1 PERLANCAR 7
2 SANKO 7
3 HAX 4
4 CONTRA 3
5 ETJ 3
6 JJNAPIORK 3
7 OODLER 3
8 MJOHNSON 2
9 GENE 2
10 BRTASTIC 2
11 LION 2
12 JANESKIL 2
13 LNATION 2
14 UTASHIRO 2
15 MATHIAS 2
16 RRWO 1
17 CLEACH 1
18 TOBYINK 1
19 TEAM 1
20 PEVANS 1
21 JAMTWOIN 1
22 GDT 1
23 SKIM 1
24 BCDE 1
25 GAISSMAI 1
26 EHUELS 1
27 JDEGUEST 1
28 JOJESSF 1
29 ABECKER 1
30 DCANTRELL 1
31 SHINGO 1
32 CAVAC 1
33 VVELOX 1
34 LEONT 1
35 WATERKIP 1
36 DOMM 1
37 CHENGYU 1
38 CEEJAY 1
39 DERIV 1
40 HORSHACK 1
41 DAKKAR 1

Working my way through some tutorials and other sources on the internet to learn Perl's DBIx. Making some progress, but the following is nagging me for some time now. Kinda at a loss

I've got 2 tables:

  • article for meta data
  • article_content for the actual content

There is an one2many relationship: 1 article having several versions of content. In the schema files it look like this:

For the article

__PACKAGE__->add_columns(
  "article_id",
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
  "title",
  { data_type => "text", is_nullable => 0 },
  "slug",
  { data_type => "text", is_nullable => 0 },
  "authorid",
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
  "created",
  { data_type => "timestamp", is_nullable => 0 },
  "abstract",
  { data_type => "text", is_nullable => 0 },
);

the relation being:

__PACKAGE__->has_many(
  "article_contents",
  "MyApp::Schema::Result::ArticleContent",
  { "foreign.articleid" => "self.article_id" },
  { cascade_copy => 0, cascade_delete => 0 },
);

For the content

__PACKAGE__->add_columns(
  "article_content_id",
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
  "articleid",
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
  "version",
  { data_type => "integer", is_nullable => 0 },
  "editorid",
  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
  "created",
  { data_type => "timestamp", is_nullable => 0 },
  "published",
  { data_type => "timestamp", is_nullable => 0 },
  "content",
  { data_type => "text", is_nullable => 0 },
);

the relation being

__PACKAGE__->belongs_to(
  "articleid",
  "MyApp::Schema::Result::Article",
  { article_id => "articleid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);

What I would like to do is get the meta data for article 1 and the content with the highest version number. Something like

Select article.title, article_content.content
Join article_content On article_content.articleid = article.article_id
Order by article_content.version DESC
Where article_id = 1
Limit 1 Offset 1

in SQL

Kinda following https://metacpan.org/release/JROBINSON/DBIx-Class-Manual-SQLHackers-1.2/view/lib/DBIx/Class/Manual/SQLHackers/SELECT.pod#SELECT-with-LIMIT-and-OFFSET to get that going and came up with the following test code

say "\nArticle 1 content versie 2";
my $article_1_rs = $schema->resultset('Article')->search(
    { 
        articleid => 1
    },
    {
        join => 'article_contents',
        order_by => {'-desc' => ['article_contents.version']},
        rows => 1,
        page => 1
    }
);

while( my $article_1 =$article_1_rs->next() ){
    say $article_1->title;
    for my $content ($article_1->article_contents){
        say $content->version, " => ", $content->content;
    }
}

This gives me:

Article 1 content versie 2
Artikel 1
1 => Inhoud artikel 1
2 => Inhoud artikel 1 versie 2

As you can see I get the content from both version which are in the database. I was expection to get only the version 2 content. Tried it without the join. A previous problem I had was solved NOT using a join, but I get no result at all without it.

Nov 19: Some further research:

Learned about about "DBIC_TRACE" and added it:

$ENV{DBIC_TRACE} = '1';

and after correcting a goofup in the article_id column name the code is now

say "\n__Article 1 content versie 2 using search__";
my $article_1_rs = $schema->resultset('Article')->search(
    { 
        article_id => 1
    },
    {
        join => 'article_contents',
        order_by => {'-desc' => ['article_contents.version']},
        rows => 1,
        page => 1
    }
);
while( my $article_1 =$article_1_rs->next() ){
    say $article_1->title;
    for my $content ($article_1->article_contents){
        say $content->version, " => ", $content->content;
    }
}

This gave me the following output (edited for clarity):

say =>__Article 1 content versie 2 using search__
SELECT 
    me.article_id, 
    me.title, 
    me.slug, 
    me.authorid, 
    me.created, 
    me.abstract 
FROM article me 
LEFT JOIN article_content article_contents ON article_contents.articleid = me.article_id 
WHERE ( article_id = ? ) 
ORDER BY article_contents.version DESC 
LIMIT ?: '1', '1'
say =>Artikel 1
SELECT 
    me.article_content_id, 
    me.articleid, 
    me.version, 
    me.editorid, 
    me.created, 
    me.published, 
    me.content 
FROM article_content me 
WHERE ( me.articleid = ? ): '1'
say =>1 => Inhoud artikel 1
say =>2 => Inhoud artikel 1 versie 2

I can see the first query is influenced by what I do in the join. It had in fact the join, the order and the offset. No columns are selected from "article_content". The second query kinda surprised me. It's a straightforward select from 'article_content' using a where on the foreign key. It makes it clear to me where the resulting data set comes from. Not the why :S

Seems the join section in the declaration of "$article_1_rs" serves no purpose. So am going to rebuild it to a find without the join, being more to the point anyway. Seeams I should be looking for a way to influence the second query. Not sure how though.

PPI Signature Parsing Ready for feedback

r/perl

Published by /u/oalders on Tuesday 19 November 2024 16:44

This has been in the works for a while, but now is a good time to leave comments on the changes: https://github.com/Perl-Critic/PPI/pull/280

submitted by /u/oalders
[link] [comments]

How to render a custom template for 403 page

Perl questions on StackOverflow

Published by user4035 on Tuesday 19 November 2024 15:49

I have a function that checks whether the current user is authorized to access the URL. I attach it to the router via add_condition:

use Mojolicious::Lite;

# Adding a custom condition
app->routes->add_condition(auth => sub {
    my ($route, $c, $captures, $num) = @_;

    $c->res->code(403);
    $c->rendered(403);
    # Here, you could define your condition. For example, check if a parameter is set.
    return 0;  # true/false depending on parameter
});

my $r = app->routes;
$r->get('/block')->requires(auth => 1)->to(cb => sub {
  my $c = shift;
  $c->render(template => 'default');
});

# Route for home
get '/' => sub {
    my $c = shift;
    $c->render(template => 'main');
};

# Default template
app->start;

__DATA__

@@ 403.html.ep
<!DOCTYPE html>
<html>
<head><title>Default Template</title></head>
<body>
<h1>Welcome to the Default Template</h1>
<p>This is the default template.</p>
</body>
</html>

@@ main.html.ep
<!DOCTYPE html>
<html>
<head><title>Main page</title></head>
<body>
<h1>Welcome to the main page</h1>
<p>The main page is here.</p>
</body>
</html>

What should I do to use a custom template for 403 page?

Vector Databases in Perl

r/perl

Published by /u/OvidPerl on Tuesday 19 November 2024 14:06

LPW 2024: Dr. Luis Mochán: Simulating Meta-Materials using Photonic in Perl

r/perl

Published by /u/briandfoy on Tuesday 19 November 2024 12:31

Perl Regex fails to compile looking for \object

Perl questions on StackOverflow

Published by Todd on Monday 18 November 2024 21:24

I am having difficulty creating a regular expression that is looking for a string similar to F:\work\object\src. I've created the following demonstration of things I've tried. Please note, that the $match is coming in from a database field, so that's why its defined as a string that is then made a RE by the qr operator.

#!/opt/perl/bin/perl
  use Try::Tiny;
  use Data::Dumper::Concise;

  my $str = 'F:\work\object\src';

  my @matches = (
      "\b F\\:\\work\\object\\src \b",
      '\b F\:\work\object\src \b',
      q{\b F\\:\\work\\object\\src \b},
      q{\b\QF:\work\object\src\E \b},
      q{\b F\\:\\work\\\\object\\src \b},
      qq{\b F\\:\\work\\\\object\\src \b},
  );

  my $i = 0;
  foreach my $match (@matches) {
      print "attempt ".$i++."\n";
      try {
          my $re  = qr{($match)}xims;
          print "Built successfully.\n";
          if ($str =~ /$re/) {
              print "Match\n";
          }
          else {
              print "But did not match!\n";
              print Dumper($re);
          }
      }
      catch {
          print "$match failed to build re\n";
          print "$_\n";
      };
  }

The output of this test program is as follows:

attempt 0
 F\:\work\object\src failed to build re
Missing braces on \o{} in regex; marked by <-- HERE in m/ F\:\work\o <-- HERE bject\sr)/ at ./reparse.pl line 20.

attempt 1
\b F\:\work\object\src \b failed to build re
Missing braces on \o{} in regex; marked by <-- HERE in m/(\b F\:\work\o <-- HERE bject\src \b)/ at ./reparse.pl line 20.

attempt 2
\b F\:\work\object\src \b failed to build re
Missing braces on \o{} in regex; marked by <-- HERE in m/(\b F\:\work\o <-- HERE bject\src \b)/ at ./reparse.pl line 20.

attempt 3
\b\QF:\work\object\src\E \b failed to build re
Missing braces on \o{} in regex; marked by <-- HERE in m/(\b\QF:\work\o <-- HERE bject\src\E \b)/ at ./reparse.pl line 20.

attempt 4
Built successfully.
But did not match!
qr/(\b F\:\work\\object\src \b)/msix
attempt 5
Built successfully.
But did not match!
qr/ F\:\work\\object\src)/msi

Attempts 4 and 5 seem to escape the \o but fail in matching the string. Would appreciate help crafting the string that will work.

I am trying to build a template for Perl scripts so that they would do at least most of the basic things right with UTF-8 and would work equally well on Linux and Windows machines.

One thing in particular escaped me for a while: the difficulty of passing UTF-8 strings as arguments to system commands. It seems to me that there is no way not to have arguments double UTF-8 encoded before they reach the shell (that is, I understand that there is a layer that ignores that the command and its arguments are already properly UTF-8 encoded, takes it for Latin-1 or something of the sorts, and encodes it again as UTF-8). I could not find a way to cleanly avoid this layer of encoding.

Take this script:

#!/usr/bin/perl

use v5.14;

use utf8;
use feature 'unicode_strings';
use feature 'fc';
use open ':std', ':encoding(UTF-8)';
use strict;
use warnings;
use warnings FATAL => 'utf8';

use constant IS_WINDOWS => $^O eq 'MSWin32';

# Set proper locale
$ENV{'LC_ALL'} = 'C.UTF-8';

# Set UTF-8 code page on Windows
if (IS_WINDOWS) {
  system("chcp 65001 > nul 2>&1");
};

# Use Win32::Unicode::Process on Windows
if (IS_WINDOWS) {
  eval {
    require Win32::Unicode::Process;
    Win32::Unicode::Process->import;
  };
  if ($@) {
    die "Could not load Win32::Unicode::Process: $@";
  };
};


# Show the empty directory
print "---\n" . `ls -1 system*` . "---\n";

my $utf = "test-тест-מבחן-परीक्षण-😊-𝓽𝓮𝓼𝓽";

# Works fine on Linux but not on Windows
print "System (touch) exit code: " . system("touch system-$utf > touch-system.txt 2>&1") . "\n";
print "System (echo) exit code: " . system("echo system-$utf > echo-system.txt 2>&1") . "\n";

if (IS_WINDOWS) {
  # Works fine on Windows
  print "SystemW (touch) exit code: " . systemW("touch systemW-$utf > touch-systemW.txt 2>&1") . "\n";
  print "SystemW (echo) exit code: " . systemW("echo systemW-$utf > echo-systemW.txt 2>&1") . "\n";
};

# Show the directory with the new the files
print "---\n" . `ls -1 system*` . "---\n";

exit;

On Linux, everything is fine: the file created with touch through system() has a UTF-8 encoded filename and the content of the file created with echo is correctly UTF-8 encoded.

Yet, I found no way to get the same code to behave correctly on Windows. There, the output of the script is this:

---
---
System (touch) exit code: 0
System (echo) exit code: 0
SystemW (touch) exit code: 
SystemW (echo) exit code: 
---
system-test-теÑÑ‚-מבחן-परीकà¥à¤·à¤£-😊-ð“½ð“®ð“¼ð“½
systemW-test-тест-מבחן-परीक्षण-😊-𝓽𝓮𝓼𝓽
---

As the script shows, the only way I could make it work is to use Win32::Unicode::Process::systemW() to replace system(). The file systemW-test-тест-מבחן-परीक्षण-😊-𝓽𝓮𝓼𝓽 is correctly named and the content of echo-systemW.txt is correctly encoded in UTF-8.

My questions are these:

  1. Is there a way to avoid using systemW() and keep the code identical for Linux and Windows but somehow remove this layer that double-encodes the system command? In other words, is this the only good way to go?

  2. If this is the right way, I am not sure how to obtain the similarly correct behaviour for backticks. They have the same problem as system() but I have no idea how to capture the output of a command with systemW() aside from piping it into a temporary file and reading that at the end (possible, of course, but maybe not great).

Perl Weekly #695 - Perl: Half of our life

dev.to #perl

Published by Gabor Szabo on Monday 18 November 2024 05:31

Originally published at Perl Weekly 695

Hi,

A month from now Randal Schwartz is going to give a presentation with the title "Half My Life with Perl". I tried to come up with a clever title for this issue of the newsletter that would reflect that title and I had to realize that I have been using Perl also for half of my life. It is probably similar for quite a lot of people in the hard-core of the Perl communities. Many have moved on to other languages. Some of those still have a nostalgic feeling for their 'first love' in the 'good old days'.

It is sad to see the decline in popularity. I remember the time when we had several conferences and workshops every year and hundreds of active Perl Monger groups with tens of monthly meetings around the world. Long before Meetup became a thing. Now there are only 18 groups listed and seeing the list of events at the bottom of this newsletter it seems only 3 or 4 are active.

The readership of this newsletter has also declined from a peak of 6,443 subscribers in May 2018 to 4,398 today.

But not all is lost. There are still people working on Perl as you can see from the grants. There are still people uploading libraries to CPAN as you can see from the recent report. There are still some people writing about Perl. There are still some companies using Perl.

Have a nice week!

--
Your editor: Gabor Szabo.

Announcements

Randal Schwartz: Half My Life with Perl

As part of year 25 of The Perl Advent Calendar, Perl luminary and co-author of O'Reilly's "Learning Perl" Randal Schwartz will be giving a presentation entitled "Half My Life with Perl". The presentation takes place on Saturday, Dec 14, 2024.

Articles

A link site of your very own

Another personal project of Dave that made it to CPAN as well. Think about it as a LinkTree clone. reddit

Discussion

Transitioning from Catalyst to Mojo, question about the model

Editing Perl Plug-in For Logitech Media Server

Grants

tony_cook

Maintaining Perl (Tony Cook) September 2024

Maintaining Perl 5 Core (Dave Mitchell): October 2024

Maintaining Perl (Tony Cook) August 2024

PEVANS Core Perl 5: Grant Report for October 2024

Perl

This week in PSC (168) | 2024-11-15 | Perl Steering Council

reddit

The Weekly Challenge

The Weekly Challenge by Mohammad Sajid Anwar will help you step out of your comfort-zone. You can even win prize money of $50 by participating in the weekly challenge. We pick one champion at the end of the month from among all of the contributors during the month, thanks to the sponsor Lance Wicks.

The Weekly Challenge - 296

Welcome to a new week with a couple of fun tasks "String Compression" and "Matchstick Square". If you are new to the weekly challenge then why not join us and have fun every week. For more information, please read the FAQ.

RECAP - The Weekly Challenge - 295

Enjoy a quick recap of last week's contributions by Team PWC dealing with the "Word Break" and "Jump Game" tasks in Perl and Raku. You will find plenty of solutions to keep you busy.

Break the Jump

Trying different approaches until you end up with one that gives the expected result. Thanks for sharing behind the scene story.

Taking A Break From All Your Worries

Clever regex magic is used to get the job done. Smart move, keep it up.

Jumping Words

Simply love the compact solution with lots of magic. Cutest contributions, well done.

loops and substitutions

Welcome back and thanks for sharing knowledge with us every week. My all time favourite is PostgreSQL solution. Keep it up great work.

Perl Weekly Challenge 295

Curious to know the benefit of the use of Memoize in the one-liner. Keep it up great work.

Jump, but Don't Break the Game

Interesting comparison of CPAN module and homemade logic. Pick your choice.

Spaced out jumps

Another good show of recursion where it does the job every efficiently. Keep up the great work.

The Weekly Challenge #295

Cool use of subroutine signature and recursive. Thanks for sharing knowledge with us every week.

Jump and Break

Demo of breadth-first search pattern in Raku for you. Highly recommended.

The Break Game

From Perl and Python expert, here we have mix of both. Easy narrative to follow, keep up great work.

Videos

Chemometrics with Perl & Pharmaceutical Applications

Weekly collections

NICEPERL's lists

Great CPAN modules released last week;
MetaCPAN weekly report;
StackOverflow Perl report.

The corner of Gabor

A couple of entries sneaked in by Gabor.

Improving the (software) development process

This seems to be a generic problem regardless of the programming language, though I wonder how does the age of the programming language and the traditions of the Open Source communities around the language impact this.

Events

Purdue Perl Mongers

December 11, 2024, Virtual event

Boston.pm monthly meeting

December 11, 2024, Virtual event

Randal Schwartz: Half My Life with Perl

December 14, 2024, Virtual event

Perl Community Conference

December 18, 2024, Virtual

Toronto.pm December Social

December 19, 2024, In Person Event

You joined the Perl Weekly to get weekly e-mails about the Perl programming language and related topics.

Want to see more? See the archives of all the issues.

Not yet subscribed to the newsletter? Join us free of charge!

(C) Copyright Gabor Szabo
The articles are copyright the respective authors.

The Weekly Challenge - 296

The Weekly Challenge

Published on Monday 18 November 2024 02:25

Welcome to the Week #296 of The Weekly Challenge.

RECAP - The Weekly Challenge - 295

The Weekly Challenge

Published on Monday 18 November 2024 02:01

Thank you Team PWC for your continuous support and encouragement.

The Weekly Challenge - Guest Contributions

The Weekly Challenge

Published on Sunday 17 November 2024 23:56

As you know, The Weekly Challenge, primarily focus on Perl and Raku. During the Week #018, we received solutions to The Weekly Challenge - 018 by Orestis Zekai in Python. It was pleasant surprise to receive solutions in something other than Perl and Raku. Ever since regular team members also started contributing in other languages like Ada, APL, Awk, BASIC, Bash, Bc, Befunge-93, Bourne Shell, BQN, Brainfuck, C3, C, CESIL, Chef, COBOL, Coconut, C Shell, C++, Clojure, Crystal, D, Dart, Dc, Elixir, Elm, Emacs Lisp, Erlang, Excel VBA, F#, Factor, Fennel, Fish, Forth, Fortran, Gembase, GNAT, Go, GP, Groovy, Haskell, Haxe, HTML, Hy, Idris, IO, J, Janet, Java, JavaScript, Julia, K, Korn Shell, Kotlin, Lisp, Logo, Lua, M4, Maxima, Miranda, Modula 3, MMIX, Mumps, Myrddin, Nelua, Nim, Nix, Node.js, Nuweb, Oberon, Octave, OCaml, Odin, Ook, Pascal, PHP, Python, PostgreSQL, Postscript, PowerShell, Prolog, R, Racket, Rexx, Ring, Roc, Ruby, Rust, Scala, Scheme, Sed, Smalltalk, SQL, Standard ML, SVG, Swift, Tcl, TypeScript, Uiua, V, Visual BASIC, WebAssembly, Wolfram, XSLT, YaBasic and Zig.

Jump, but Don't Break the Game (PWC 295)

dev.to #perl

Published by Matthias Muth on Sunday 17 November 2024 22:28

These are my solutions in Perl
for Challenge 295 Tasks 1 and 2 of The Weekly Challenge - Perl and Raku.

Summary

Task 1: Word Break.
A simple regular expression, built from the word list, delivers the solution. Very short, very nice.

Task 2: Jump Game
Implementing an unspectacular 'breadth first search' (BFS) algorithm.

Task 1: Word Break

You are given a string, $str, and list of words, @words.

Write a script to return true or false whether the given string can be segmented into a space separated sequnce of one or more words from the given list.

Example 1

Input: $str = 'weeklychallenge', @words = ("challenge", "weekly")
Output: true

 
Example 2

Input: $str = "perlrakuperl", @words = ("raku", "perl")
Output: true

 
Example 3

Input: $str = "sonsanddaughters", @words = ("sons", "sand", "daughters")
Output: false

We need to recognize words from the input word list in the string, making sure that after each recognized word, another word from the list begins.

That means we are checking whether the string is a sequence of one or more words from the list.
Wait a second...! Checking 'one or more' occurrences of something in a string?
What could be easier than using a regular expression for that?
The 'one or more' part directly translates to a + quantifier.

And the pattern? We form it as a list of alternatives, using the '|' character do separate the choices.

Then, we only have to match the string against our pattern:

use v5.36;

sub word_break( $str, $words ) {
    my $pattern = join "|", $words->@*;
    return $str =~ /^($pattern)+$/;
}

That was an easy one.

Task 2: Jump Game

You are given an array of integers, @ints.

Write a script to find the minimum number of jumps to reach the last element.
$ints[$i] represents the maximum length of a forward jump from the index $i.
In case last element is unreachable then return -1.

Example 1

Input: @ints = (2, 3, 1, 1, 4)
Output: 2
Jump 1 step from index 0 then 3 steps from index 1 to the last element.

 
Example 2

Input: @ints = (2, 3, 0, 4)
Output: 2

 
Example 3

Input: @ints = (2, 0, 0, 4)
Output: -1

Now this one requires some 'real programming'(tm).

First, let's get clear about the game mechanics. The description says:

$ints[$i] represents the maximum length of a forward jump from the index $i.

If we take $ints[$i] == 3 as an example, that means that we can choose to jump to $i+1, $i+2 or $i+3 in that move.
For each of those, the next move continues with the number that we find there.

Trying all possible combinations from the first entry in the list is like building a tree of possible paths. The root node is $int[0]. From there, there is one outgoing branch for every possible jump from there.

To find the 'shortest path' to the last entry, we need to find the shortest path in that tree that leads to a node with the index value of the last entry.

Finding the shortest path in a tree is typically done using a 'breadth first search' (or 'BFS') algorithm. All of the nodes on the same level ('breadth') are checked before any nodes on higher levels. So if one fulfils the end condition (here: it's the index of the last entry in the list), it's garanteed that there are no shorter paths.

A BFS algorithm is not difficult to set up:
We use a queue for the nodes to check.
For the queue entries, we use two-element anonymous arrays, containing the index value, and the length of the path that was needed to reach that node. That makes it easy to return the correct result once we find the shortest path.

We initialize our queue with the index of the first number in the list (which is 0, of course), and the number of jumps needed to get there (0, too!).
This represents the starting point of our tree.

Then we loop over the entries in the queue.
For each entry, we check whether it meets the end condition, and return the path length if it does. Done.

If we haven't reached the last entry yet, we add the next level of possible moves to the queue, making sure we don't add jumps that end beyond the end of the list.
The path length for these new queue entries is one higher than the one that we have so far.

If the queue runs empty, there is no possible path that reaches the last entry. We return the -1 as we should in that case.

use v5.36;

sub jump_game( @ints ) {
    my ( $index, $n_jumps ) = ( 0, 0 );
    my @queue = ( [ $index, $n_jumps ] );
    while ( @queue ) {
        my ( $index, $n_jumps ) = ( shift @queue )->@*;
        return $n_jumps
            if $index == $#ints;
        push @queue,
            map [ $_, $n_jumps + 1 ],
                grep $index <= $#ints,
                    reverse $index + 1 .. $index + $ints[$index];
    }
    return -1;
}

This BFS does not need a 'visited' structure to avoid running into circles. As we only move forward in the list, we don't need to fear running into that problem at all.

I have also created a solution using the Algorithm::Functional::BFS module from CPAN. It hides all the mechanics of the BFS algorithm and uses a functional approach: there are code blocks handed in to the search function, for checking whether a node meets the the end criteria, and for getting the list of successor nodes for a node. These are the only two variable parts of the algorithm.

In fact I found that the code is not significantly shorter when I use that module, because we need to supply the code blocks as parameters, and also set some parameters. So I am quite ok with having written it myself.

Thank you for the challenge!

Find the complete source code for both tasks, including tests and alternative solution implementations, on Github.

A link site of your very own

Perl Hacks

Published by Dave Cross on Sunday 17 November 2024 17:19

When I first wrote about my pointless personal side projects a few months ago, I used the software I had written to generate my own link site (like a LinkTree clone) as an example.

I’m happy to report that I’ve continued to work on this software. Recently, it passed another milestone—I released a version to CPAN. It’s called App::LinkSite[*]. If you’d like a Link Site of your own, there are a few ways you can achieve that.

In all cases, you’ll want to gather a few pieces of information first. I store mine in a GitHub repo[**].

Most importantly, you’ll need the list of links that you want to display on your site. These go in a file called “links.json“. There are two types of link.

  1. Social media links. These appear as a row of icons across the top of your link site. I’ve covered most of the popular options, but if there are any more you need, just raise an issue against the repo.
  2. Standard links. These go to web sites, blogs and things like that. In every case, you’ll need the link and a title to display. You can optionally add a subtitle and a “new” flag (which will slightly change the way the link is displayed – to make it more obvious).

There are also a few bits of header information you’ll want to add:

  • Name
  • Default handle – this is displayed on the page, but also used as the default handle in your social media links
  • Image – presumably your picture
  • Open Graph Image – which is optionally added to the header of the site
  • The URL of your site – used for various SEO tags in the output
  • Description
  • Optional Google Analytics 4 Tag

Put all of that information into “links.json” and put the images in a directory called “img”. Fuller documentation is in the README.

Now you get to decide how you’re going to build your site.

Installed CPAN module

You can install the module (App::LinkSite) using your favourite CPAN installation tool. Then you can just run the “linksite” command and your site will be written to the “docs” directory – which you can then deploy to the web in whatever way you prefer.

Docker image

I build a Docker image whenever I release a new version of the code. That image is released to the Docker hub. So if you like Docker, you can just pull down the “davorg/links:latest” image and go from there.

GitHub Actions and GitHub Pages

But this is my favourite approach. Let GitHub do all the heavy lifting for you. There’s a little bit of set-up you’ll need to do.

  • Store the “links.json” and the images in a new repo in GitHub
  • Create a “.github/workflows” directory in your new repo and copy my “build.yaml” workflow into that directory

Now, whenever you change anything in your repo, your site will be rebuilt and redeployed automatically. There’s also a “run this workflow” under the “Actions” tab of your repo that allows you to run the build and deployment automatically whenever you want.

This is the mechanism I like best – as it’s the least amount of work!


If you try this, please let me know as I’d like to add an “Examples” section to the README file. Also, if you try it and have problems getting it working, then let me know too. It works for me, but I’m sure I’ve forgotten to cater for some specific complexity of how other people would like to use my software. I’m always happy to get suggestions on how to improve things – even if it’s just better documentation.

[*] My continued use of the new Perl class syntax still seems to be causing problems with the CPAN infrastructure. The distribution isn’t being indexed properly.

[**] This shouldn’t be too much of a surprise – I store pretty much everything in a GitHub repo.

The post A link site of your very own appeared first on Perl Hacks.

Maintaining Perl (Tony Cook) September 2024

Perl Foundation News

Published by alh on Sunday 17 November 2024 12:17


Tony writes: ``` [Hours] [Activity] 2024/09/02 Monday 0.12 #22547 comment 0.13 #21246 review and comment 1.58 #22415 research and comment 0.22 #22541 review and approve 0.20 #22125 comment 0.13 #22539 review and approve 0.43 #22380 apply to blead, perldelta

0.93 #22552 review and approve with comment

3.74

2024/09/03 Tuesday 0.77 #22563 review, research and approve 2.22 #22542 debugging, research and comment

0.88 #22125 testing, research how to get this to link correctly

3.87

2024/09/04 Wednesday 0.10 #22547 comment 0.43 #22542 comment 1.08 #22552 follow-up fix for bareword dup filehandles, push for CI 0.40 #22415 comment 0.55 #22541 research and comment 0.08 #22552 review CI results, make PR 22568 0.38 #21246 comment 0.30 #22466 comment 0.33 #22568 apply to blead, perldelta

0.60 #21550 testing, comment

4.25

2024/09/05 Thursday 0.12 #21550 review response, close with comment 0.57 #21874 review discussion, re-check commit, approve 0.47 #22572 comment 0.47 #22571 research and comment

1.90 #22542 work on a fix

3.53

2024/09/06 Friday 0.22 #22542 clean up, push for CI

0.47 #22571 research and comment

0.69

2024/09/09 Monday 0.10 #22542 check CI results, minor reword, make PR 22582 1.13 #22572 review and comments 0.48 #22582 follow-up comments 0.18 #21246 research and comment 0.10 #22550 review and approve 0.08 #22560 review and approve 0.37 #22559 review and comment 0.20 #22572 review updates and approve

0.58 #21246 look into possible test

3.22

2024/09/10 Tuesday 0.10 #22583 review, approve karl’s comment 1.30 #22577 testing, research and comment 0.72 #22542 re-work PR based on comments, push 0.72 #22547 look up eval outer scopes thing (not as relevant as I though) and comment 0.62 #22584 check for build warnings (saw a warning go past, but not this one) and create PR 22584 with fix

0.67 #22577 try to understand bodies_by_type

4.13

2024/09/11 Wednesday 0.10 #22584 apply to blead 0.23 #22575 review and approve 0.23 #22576 review and comment 1.65 #22580 review 0.90 #22580 review up to ParseXS: generate_init(): add defer, no_init param

0.87 fix sv_gets() “append” overflow, push for CI

3.98

2024/09/12 Thursday 0.08 #22576 review updates and approve 0.25 #22586 review, test on macos, approve 1.87 fix sv_gets() “append” overflow: more tests, push for CI 0.52 fix sv_gets() “append” overflow: check CI results, only failure appears to be a github issue, get it to run, open PR 22587

2.12 #22580 more review and comment

4.84

2024/09/13 Friday 0.08 #22587 fix typo, rebase, push for CI 0.32 #22542 apply to blead, perldelta

0.25 #22587 review CI results to this point, perldelta

0.65

2024/09/16 Monday 0.18 #22593 review and comment 0.15 #22594 review and approve 0.10 #22595 review and approve 0.25 #22598 review and approve 0.10 #22599 review and approve 0.08 #22600 review and approve

1.17 #1420 debugging

2.03

2024/09/17 Tuesday 1.53 #22585 research and comment

2.22 #22606 try to reproduce, debugging, comment

3.75

2024/09/18 Wednesday 0.52 discussion with khw, review github notifications 0.37 #22606 testing, comment 1.45 #22585 more research and comment 0.58 #22602 testing, code checks, comment 2.50 #22577 debugging, understand the code and despair, work on

a fix, testing, push for CI

5.42

2024/09/19 Thursday 1.55 #22585 research and comment 0.12 #22577 check CI results, make PR 22609 0.72 #22602 work on a fix (mostly working) 0.42 respond to security list 0.25 #22602 work up a test, testing, commit message, push for

CI

3.06

2024/09/20 Friday

0.67 #22602 minor fix, comments

0.67

2024/09/23 Monday 0.08 github notifications 0.23 #22617 look over the IO tests and comment 0.65 #22585 research and comment 0.47 review maint-votes and vote 0.27 #22619 review and approve

0.20 #22588 comment

1.90

2024/09/24 Tuesday 1.38 #22577 try to see win32 issue, comment 0.58 #22577 rewrite commit message 0.17 #22577 more rewrite commit message

1.47 check coverity scan results

3.60

2024/09/25 Wednesday 2.75 #22577 more win32 testing, debugging, research and comment 0.10 #19031 comment 0.50 #22622 look over the code, mauke did a better follow-up

0.30 #22623 review, research and comment

3.65

2024/09/26 Thursday 0.17 #22621 review and approve 0.60 #22615 review, research and approve 0.82 #22602 research 0.12 #22585 comment

1.42 #21877 debugging

3.13

2024/09/30 Monday 0.88 github notifications 0.93 #22195 testing and re-reproduce, start update to see if it’s fixed (and be able to test from source) 0.32 #22626 review and approve 0.08 #22624 review and approve 0.47 #22195 get build from source started 0.42 #22195 reproduce from build, look over patches, research

fedora patches and comment

3.10

Which I calculate is 63.21 hours.

Approximately 50 tickets were reviewed or worked on, and 4 patches were applied. ```

Maintaining Perl 5 Core (Dave Mitchell): October 2024

Perl Foundation News

Published by alh on Sunday 17 November 2024 12:13


Dave writes:

This is my monthly report on work done during October 2024 covered by my TPF perl core maintenance grant.

I spent most of last month continuing to do various bits of code refactoring and test-adding on Extutils::ParseXS, as a precursor to adding reference-counted stack (PERL_RC_STACK) abilities to XS.

SUMMARY: * 9:23 process p5p mailbox * 47:46 refactor Extutils::ParseXS

Total: * 57:09(HH::MM)

Maintaining Perl (Tony Cook) August 2024

Perl Foundation News

Published by alh on Sunday 17 November 2024 12:11


Tony writes:

``` [Hours] [Activity] 2024/08/01 Thursday 0.42 #22450 review updates, discussion, approve with comment 0.47 #22451 review, testing and approve 0.17 #22436 review and approve with comment 0.62 #22441 review and comment 1.28 #21524 provide patches to Promise-ES6

1.20 #1420/#19124 more review, cleanup, push for CI

4.16

2024/08/05 Monday 0.10 #22444 no follow-up discussion, recheck and approve 0.37 #20317 research and comment 0.80 #21636 rebase, fix mentioned issue, review, force push 1.08 #22465 review, research, comment

0.33 #22457 review, testing

2.68

2024/08/06 Tuesday 0.22 #22465 review updates and approve 0.12 #22459 review and approve 0.23 #22467 review, research and approve 0.45 #22469 review, comment, approve 0.27 #22466 review and ask for more information 0.10 #22441 review updates and approve 1.30 review latest coverity scan warnings 2.60 more coverity scan results, work on fix for minor

threads.xs locking issue

5.29

2024/08/07 Wednesday 0.12 #21636 brief recheck, apply to blead 0.53 #22450 re-review and approve 0.62 threads.xs coverity fix, testing, push for CI 0.52 #22303 fixes based on comments 0.08 #22477 review and approve 0.08 #22470 review and approve 0.08 #22471 review and approve 0.13 #22472 review and approve 0.10 #22473 review and approve with comment 0.17 follow-up email on coverity scan issue 0.42 #22474 review, research and comment 0.27 #22475 review, research and approve 0.18 #22476 review and approve 0.67 #22478 review, testing, research, longish comment 0.08 #22481 review and approve 0.07 #22482 review and approve 0.07 #22485 review and approve

0.80 #22303 more fix

4.99

2024/08/08 Thursday 0.27 github notifications 2.12 #22487 work on a reproducer, longish comment 0.55 #1420 re-work 0.18 #22490 look over the failure, briefly comment

1.63 #1420 more re-work saves

4.75

2024/08/12 Monday 1.20 #22493 review, review related email from jkeenan 1.63 #22303 check rebase, fix minor issue, update version checks for cpan/ updates, apply to blead, perldelta, follow-up to cpan dists, parent 1.20 #22303 upstream scalar-list-utils has some related changes, post pr #133 with extras 0.20 #22503 minor fix

0.08 #22487 brief comment

4.31

2024/08/13 Tuesday 0.28 #22503 more minor fixes 1.67 #22493 comment on tests for debug output, review, comment on one commit 0.08 #22479 review and approve 0.12 #22484 review and approve 0.18 #22492 review and approve 0.12 #22496 review and approve 0.13 #22497 review and comment

1.95 #22497 work on a real fix, make pr #22505

4.53

2024/08/14 Wednesday

1.30 #22497 minor fixes, comment

1.30

2024/08/15 Thursday 0.42 #22508 fix upstream (apostrophe in name) 0.72 goto into block removal: research (delay for now, it would conflict with smart match removal which is ready to apply once github is back) 0.92 smartmatch removal: apply to blead, work on perldelta 0.28 #22511 BBC; review failure, code and comment 1.58 #22466 try multiarch build on modern macos, review failed build logs and configuration info, comment

0.13 #22505 follow-up comment

4.05

2024/08/19 Monday 0.10 github notifications 0.18 #22466 comment 0.22 #22503 apply to blead 0.68 #22512 rebase, list some CPAN alternatives 0.13 #22505 apply to blead 0.35 ppc 54 review 0.43 #22478 comment 0.72 #21524 follow-up on Promise-ES6/#14 0.32 #22514 review and approve

1.00 #22507 review, research and comment

4.13

2024/08/20 Tuesday 2.92 #22125 testing, look into how to detect the mismatch (the XS_* macros are very XS tied)

0.23 #22125 work on code to check api

3.15

2024/08/21 Wednesday 0.55 #22524 comment as requested on patch to Scope::Upper at rt.cpan.org#154985 1.80 #22519 review, minor comments 0.52 #22521 review 0.10 #22521 continue review and approve 0.35 #22520 find the change being documented, review and approve 2.05 #22487 try a fix, search for PL_curinterp and find it,

work on fix, testing, push for CI

5.37

2024/08/22 Thursday 1.03 ppc #54 review discussion, comments 0.22 #22519 review updates and approve 0.10 #19031 review recent updates (still no docs) 0.10 #22487 check CI results, open PR 22530 0.17 #22529 review and approve 0.17 #22525 review and approve 0.67 #22125 more api version check 0.68 #22125 finish version check code, testing, commit (need to

do the actual fix next)

3.14

2024/08/28 Wednesday 0.33 github notifications 0.08 #21212 review update and approve 0.80 #21550 research and comment 0.20 #22474 review updates and approve 0.12 #21246 comment 0.03 #22231 comment 1.08 #22530 research and comment 0.13 #22534 review and approve 0.30 #22537 review and comment 0.27 #22539 comments 0.68 #22540 review, research and comments 0.65 #22541 review, comment 0.13 #22543 review and approve

0.68 #22545 research

5.48

2024/08/29 Thursday 0.75 github notififications 0.52 #22541 more review, comments

0.42 #22231 apply to blead, perldelta

1.69

Which I calculate is 59.02 hours.

Approximately 64 tickets were reviewed or worked on, and 5 patches were applied. ```

PEVANS Core Perl 5: Grant Report for October 2024

Perl Foundation News

Published by alh on Sunday 17 November 2024 12:05


Paul writes:

Hours:

  • 4 = meta module sub signature queries and bugfixes
    • https://metacpan.org/release/PEVANS/meta-0.012/source/Changes
  • 5 = Optimisations for foreach on builtin::indexed
    • https://github.com/Perl/perl5/pull/22641
  • 5 = Beginnings of improvements to subroutine signatures in core.
    • Experiment with the idea of no-snails (don't populate @_) and prepare for implementing named parameters as per PPC0024. https://github.com/leonerd/perl5/tree/faster-signatures

Total: 14 hours

The Break Game

dev.to #perl

Published by Simon Green on Sunday 17 November 2024 09:37

Weekly Challenge 295

Each week Mohammad S. Anwar sends out The Weekly Challenge, a chance for all of us to come up with solutions to two weekly tasks. My solutions are written in Python first, and then converted to Perl. It's a great way for us all to practice some coding.

Challenge, My solutions

Task 1: Word Break

Task

You are given a string, $str, and list of words, @words.

Write a script to return true or false whether the given string can be segmented into a space separated sequence of one or more words from the given list.

My solution

With TWC, I tend to think about how I would solve it on my commute home on Monday. I thought of the example of a string of winwine and the words win and wine, and also the string of winewin. There doesn't seem to be a deterministic way of seeing what word I should match first.

A few days later, I had a genius idea that I was actually solving the wrong problem. A much easier solution was to use regular expressions to see if one or more words matched the string s.

And that's what I wrote. I use re.escape in Python, and quotemeta in Perl to escape any special meta-characters in the words list.

def word_break(s: str, words: list) -> bool:
    pattern = '^(' + '|'.join(map(re.escape, words)) + ')+$'

    return True if re.search(pattern, s) else False

Examples

$ ./ch-1.py weeklychallenge challenge weekly
true

$ ./ch-1.py perlrakuperl raku perl
true

$ ./ch-1.py sonsanddaughters sons sand daughters
false

Task 2: Jump Game

Task

You are given an array of integers, @ints.

Write a script to find the minimum number of jumps to reach the last element. $ints[$i] represents the maximum length of a forward jump from the index $i. In case last element is unreachable then return -1.

My solution

When completing these tasks, I also use TDD, something I don't do in my day job. If the test fails, usually there is either an obvious error or something a little more tricky. This task was one of later. Lots of debugging ensued.

I know both Python and Perl have excellent built in debugging tools, but I'm still a fan of use a copious amount of print statements.

For this task, I have a recursive function called jump_game. It takes two parameters: ints is the list of integers (starting with the complete list), and moves which starts at one.

If the first integer is 0, I return None (undef in Python) as no further move is possible. I then iterate - with a variable i -from the value of int[0] to 1. If this value is greater than or equal to one less than the length of list, we have a solution and I return moves. For other values, I call the function again removing the i first values, and incrementing moves by one.

I have a min_moves variable to ensure we return the minimum number of moves for all the iterations.

def jump_game(ints: list, moves=1) -> int:
    min_moves = None
    for i in range(ints[0], 0, -1):
        if i >= len(ints)-1:
            return moves

        if ints[i] == 0:
            continue

        m = jump_game(ints[i:], moves+1)
        if m is not None and (min_moves is None or min_moves > m):
            min_moves = m

    return min_moves

What was my bug, you ask? I was checking for i >= len(ints) instead of i >= len(ints)-1.

Examples

$ ./ch-2.py 2 3 1 1 4
2

$ ./ch-2.py 2 3 0 4
2

$ ./ch-2.py 2 0 0 4
-1

(dxxii) 8 great CPAN modules released last week

Niceperl

Published by Unknown on Saturday 16 November 2024 22:55

Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12.

  1. App::cpm - a fast CPAN module installer
    • Version: 0.997019 on 2024-11-16, with 72 votes
    • Previous CPAN version: 0.997018 was 1 month, 23 days before
    • Author: SKAJI
  2. DBD::mysql - A MySQL driver for the Perl5 Database Interface (DBI)
    • Version: 5.010 on 2024-11-11, with 57 votes
    • Previous CPAN version: 5.009 was 1 month, 22 days before
    • Author: DVEEDEN
  3. HTTP::Tiny - A small, simple, correct HTTP/1.1 client
    • Version: 0.090 on 2024-11-12, with 114 votes
    • Previous CPAN version: 0.088 was 1 year, 4 months, 1 day before
    • Author: HAARG
  4. Imager - Perl extension for Generating 24 bit Images
    • Version: 1.025 on 2024-11-16, with 67 votes
    • Previous CPAN version: 1.024 was 7 months, 10 days before
    • Author: TONYC
  5. Net::AMQP::RabbitMQ - interact with RabbitMQ over AMQP using librabbitmq
    • Version: 2.40014 on 2024-11-09, with 15 votes
    • Previous CPAN version: 2.40013 was 25 days before
    • Author: MSTEMLE
  6. Object::Pad - a simple syntax for lexical field-based objects
    • Version: 0.815 on 2024-11-13, with 45 votes
    • Previous CPAN version: 0.814 was 1 month, 23 days before
    • Author: PEVANS
  7. SPVM - The SPVM Language
    • Version: 0.990031 on 2024-11-16, with 33 votes
    • Previous CPAN version: 0.990029 was 9 days before
    • Author: KIMOTO
  8. Text::CSV_XS - Comma-Separated Values manipulation routines
    • Version: 1.57 on 2024-11-12, with 102 votes
    • Previous CPAN version: 1.56 was 3 months, 3 days before
    • Author: HMBRAND

This week in PSC (168) | 2024-11-15

blogs.perl.org

Published by Perl Steering Council on Saturday 16 November 2024 20:16

Another extended meeting, which everyone attended. Here’s a summary:

  • We want to get actual implementation of TLS in core underway. Paul volunteered for some of it. We’ll email our plan to p5p, to get things started.
  • We talked about undef-aware equality operators. While the flags idea is tempting, we don’t think that there are enough useful flags to go down this route (what’s the use of stacking flags, if you only have one). If equ and === are added to Perl, we think the negative versions (neu and !==) should be added as well.
  • We had a quick version discussion. The document is almost ready.
  • We want to poke the PPC implementors again, to make sure we can have some of them available in the next version of Perl.

[P5P posting of this summary]

Randal Schwartz: Half My Life with Perl

perl.com

Published on Thursday 14 November 2024 12:00

As part of year 25 of The Perl Advent Calendar, Perl luminary and co-author of O’Reilly’s “Learning Perl” Randal Schwartz will be giving a presentation entitled “Half My Life with Perl”.

The presentation takes place on Saturday, Dec 14, 2024.

Randal says:

Having been there, at the beginning with Perl, I will recount the early days through the modern era (or as much as I can cover in the time provided). I’ll deliver first-hand experience of the creation of the Camel Book, the Llama book, and the way I invaded comp.unix.questions with Perl 2 answers so often that people would post “no Perl please”. Oh, and my version of the story of the Schwartzian Transform.

This event will be a live stream via Zoom. The stream URL will be provided via the event page as we get closer to the date.

📹 If you can’t make the live stream, don’t worry — the event will be recorded and added to this year’s Perl Advent Calendar.

If you’d like to be notified about the recording, please register for the event and we’ll send out a blast with the Advent Calendar URL once it has become available.

Why Perl Is Better Than JavaScript for Server-Side Scripting?

Perl on Medium

Published by Mayur Koshti on Wednesday 13 November 2024 08:36

Perl and JavaScript are two languages that developers often consider for server-side work, but they come with qufeatures.

Raku: Why It Hasn’t Caught On

Perl on Medium

Published by Greg Donald on Wednesday 13 November 2024 02:12

In the vast realm of modern programming languages, some rise to prominence while others remain forever in the shadows. Raku, initially…

RECAP - The Weekly Challenge - 294

The Weekly Challenge

Published on Monday 11 November 2024 22:08

Thank you Team PWC for your continuous support and encouragement.

The Weekly Challenge - 295

The Weekly Challenge

Published on Monday 11 November 2024 22:06

Welcome to the Week #295 of The Weekly Challenge.

Perl Weekly #694 - LPW: Past, Present & Future

dev.to #perl

Published by Gabor Szabo on Monday 11 November 2024 05:32

Originally published at Perl Weekly 694

Hi there,

It has been two weeks since the London Perl and Raku Workshop 2024, and we are still receiving attendee reports. Thank you to everyone who took the time to share their experiences. Last week, I came across two such reports by Lee Johnson and Olaf Alders. I'm still hoping to find a moment to reflect on my own workshop experience.

LPW holds a special place in my heart, as it was the first workshop where I gave my first talk ever. I was introduced to LPW by a colleague at work. Back then, there was always an O'Reilly stall outside the theater room, selling Perl books and surrounded by a large crowd. I remember the days when we had three strong tracks running simultaneously and, especially, the last LPW organized by Mark Keating and his team. The transition was seamless, and we continued the workshop smoothly until COVID-19 struck. For a brief period, I was part of the organizing team, but my contributions were limited to promoting the event and assisting attendees on the day.

Bringing the workshop back after COVID-19 was the brainchild of Lee Johnson and Julien Fiegenhenn. Their hard work truly paid off, as the event was well-attended and praised for its smooth execution. I would like to take this opportunity to thank the organizing team for providing a platform to reconnect with friends from around the world. The future of LPW looks bright as I’m hearing a lot of positive feedback about next year’s workshop, and I'm keeping my fingers crossed.

Enjoy rest of the newsletter.

--
Your editor: Mohammad Sajid Anwar.

Announcements

London Perl & Raku Workshop 2024: Recordings & Thoughts

For all who missed the LPW 2024, we now have the recordings of the event. Audio quality may not be great, I must inform you upfront.

Articles

This week in PSC (167) | 2024-11-07

It seems very busy week, lots of topics discussed amd agreed upon. Happy to see things moving really fast. Thank you Perl Steering Council.

Multiple Inheritance vs Role

A simplified comparison between Multiple Inheritance and Roles.

Further on Perl Camel

The good old discussion of Perl Camel is back ...

Discussion

I wish Mojo::UserAgent could be made to not visit private IPs

An interesting discussion started around the use of Mojo::UserAgent. What is your view on this?

Grants

Dancer2 Documentation Grant Report

Great to see the improvement work being carried out in my favourite web framework, Dancer2.

The Weekly Challenge

The Weekly Challenge by Mohammad Sajid Anwar will help you step out of your comfort-zone. You can even win prize money of $50 by participating in the weekly challenge. We pick one champion at the end of the month from among all of the contributors during the month, thanks to the sponsor Lance Wicks.

The Weekly Challenge - 295

Welcome to a new week with a couple of fun tasks "Word Break" and "Jump Game". If you are new to the weekly challenge then why not join us and have fun every week. For more information, please read the FAQ.

RECAP - The Weekly Challenge - 294

Enjoy a quick recap of last week's contributions by Team PWC dealing with the "Consecutive Sequence" and "Next Permutation" tasks in Perl and Raku. You will find plenty of solutions to keep you busy.

TWC294

Rare pairing of 'unless' inside 'foreach' and we have a compact solution, very impressive. Please keep sharing knowledge with us.

Next Consecutive

The verbosity of solutions is the main attraction for me, not just this week but every week. It gives away lots of inner details. Great work, keep it up.

Perl Weekly Challenge: Week 294

Making good use of Raku built-in functions and getting job done in no time. Smart move, well done.

Consecutive Permutations

A very interesting discussion about the use of data structure to get around O(n) time. It's worth checking out, thanks for sharing.

Perl Weekly Challenge 294

Compact one-liner in Perl for all with enough discussion to get to the core. Well done and keep it up.

Consecutive Sequences of Permutations, Anyone?

The detailed analysis to sort out the O(n) time is very impressive. There is always something new to learn from your contributions.

No music, only numbers

Anyone looking for Raku magic then this is the best place where Raku implementation is discussed in details. Having said, I missed the musical aspect.

Sequential permutations

A detailed proof of O(n) time is worth checking. Kudos for the effort, thanks for sharing knowledge with us.

The Weekly Challenge #294

Thanks for sharing the research of finding the lexicographically next permutation. Plenty to learn from this week work.

Permutationally Consecutive

Another dose of Raku gems discussed and it is not to be missed. Highly recommended.

Rakudo

2024.43 One Of 21

Weekly collections

NICEPERL's lists

Great CPAN modules released last week;
MetaCPAN weekly report.

Event reports

Smashed TVs, Broken Windows, and Cracked Plates

Hear from the organiser of LPW what it takes to origanise an event. Kudos for all thier efforts.

How I Spent My First London Perl Workshop

A very colorful presentation, I must admit. Glad that you had great time in London.

Events

Boston.pm monthly meeting

November 12, 2024, Virtual event

Purdue Perl Mongers

November 13, 2024, Virtual event

Toronto Perl Mongers monthly meeting

November 28, 2024, Virtual event

Purdue Perl Mongers

December 11, 2024, Virtual event

You joined the Perl Weekly to get weekly e-mails about the Perl programming language and related topics.

Want to see more? See the archives of all the issues.

Not yet subscribed to the newsletter? Join us free of charge!

(C) Copyright Gabor Szabo
The articles are copyright the respective authors.

Consecutive Sequences of Permutations, Anyone? (PWC 294)

dev.to #perl

Published by Matthias Muth on Sunday 10 November 2024 23:29

Challenge 294 solutions in Perl by Matthias Muth

These are my Challenge 294 Task 1 and 2 solutions in Perl
for The Weekly Challenge - Perl and Raku.

Summary

Task 1: Consecutive Sequences
O(n)O(n) O(n) solution using a small data structure and a lookup hash to keep track of 'streaks' (consecutive sequences) and to merge them with new numbers as they are processed.

Task 2: Next Permutation
Working 'locally' to flip numbers to get the next permutation, without the need to create all permutations first.

Code:
Find the complete source code for both tasks, including more tests, on Github.

Task 1: Consecutive Sequence

You are given an unsorted array of integers, @ints.
Write a script to return the length of the longest consecutive elements sequence. Return -1 if none found. The algorithm must runs in O(n) time.

Example 1
Input: @ints = (10, 4, 20, 1, 3, 2)
Output: 4
The longest consecutive sequence (1, 2, 3, 4).
The length of the sequence is 4.

Example 2
Input: @ints = (0, 6, 1, 8, 5, 2, 4, 3, 0, 7)
Output: 9

Example 3
Input: @ints = (10, 30, 20)
Output: -1

Oh. Big Oh. O(n)O(n) O(n) !

This restriction means that the simplest solution, sorting the array and then walking through the ordered numbers, is not allowed. That's because sort has an O(nlog⁡n)O(n \log{} n) O(nlogn) time complexity.

So what we are allowed to do for O(n)O(n) O(n) is to walk through the array. As long as we don't use another loop within a loop, we can even walk through the array several times. This only means that the runtime spent for each number is slightly higher, but this still scales linearly with rising nn n . Actually O(2n)O(2n) O(2n) is the same as O(n)O(n)O(n) .

In fact I do walk through the data twice! I use uniq on the input data, as a first pass (Example 2 contains a 0 twice!). I do this to make sure that double entries do not disturb the detection of sequences.

Let's call a 'consecutive sequence' a 'streak' for short.
We need to build up the 'streaks' as we encounter the numbers, one by one.
The data structure I use for representing a streak is a simple hash:

    $streak = { FROM => $a, TO => $b };

When a new number is encountered, I try to merge that number with any streak that already exists at the number's immediate left or immediate right.

For knowing whether those neighboring streaks already exists , I keep a lookup hash, %streaks. For every streak I create, I put a reference to the streak's data structure into that lookup hash, one with its starting number as the key, and one with its ending number. Thus, to access the left and right neighboring streaks for any new number $n, I only need to check $streaks{ $n - 1 } and $streaks{ $n + 1 }.. And once I have those, I know their 'other ends': the left streak's starting number, and the right streak's ending number. I then can create a new streak that covers them all, the left streak, the new number, and the right streak (if they exist, that is).

What is left to do then is to update the lookup table. I delete any references to the left and right streaks that will not be needed anymore, and I store references to the merged streak in the lookup hash at its starting and ending numbers.

For returning the length of the longest streak in the end, I check whether the new one is longer than what we already have, and update accordingly.

I have left the comments inside the code to make it easier to follow:

use v5.36;
use List::Util qw( uniq );

sub consecutive_sequence_using_hash( @ints ) {
    my $max_streak_length = -1;
    my %streaks;
    for my $n ( uniq @ints ) {
        # Create a new streak from this number,
        # possibly merged with any existing adjacent streaks
        # to the left or to the right.
        my ( $left, $right ) =
            ( $streaks{ $n - 1 }, $streaks{ $n + 1 } );
        my ( $from, $to ) = (
            $left ? $left->{FROM} : $n,
            $right ? $right->{TO} : $n,
        );
        my $streak = { FROM => $from, TO => $to };

        # Update the lookup entries:
        # Remove any entries that are *inside* the merged streak,
        # and add or update entries at the streak borders.
        delete $streaks{ $left->{TO} }
            if $left;
        delete $streaks{ $right->{FROM} }
            if $right;
        $streaks{$from} = $streaks{$to} = $streak;

        # Update the maximum length if this is a streak
        # (not just a single number) and it's longer than what we have.
        $max_streak_length = $to - $from + 1
            if $to > $from && $to - $from + 1 > $max_streak_length;
    }
    return $max_streak_length;
}

No loops inside!
I think this is proper O(n)O(n) O(n) solution.

Task 2: Next Permutation

You are given an array of integers, @ints.
Write a script to find out the next permutation of the given array.
The next permutation of an array of integers is the next lexicographically greater permutation of its integer.

Example 1
Input: @ints = (1, 2, 3)
Output: (1, 3, 2)
Permutations of (1, 2, 3) arranged lexicographically:
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)

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

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

A simple, but compute-intensive solution would be to create all permutations of the numbers involved, then sort them ('lexicographically'), then find the entry that corresponds to the permutation that is given, and then return the next one.
Actually I don't like this approach too much, because in my experience, anything that has to do with permutations or combinations has a tendency to use a lot of time , or a lot of memory, or both, very fast.

Let's find a solution that works 'locally'!

In order to modify an existing permutation to the next higher one, we need to find the number with the lowest significance that can be increased.
That means that we start at the right end (least significant), and find the first number that is lower than its right neighbor. All numbers at the right of that are ordered, highest first, so they can't be 'incremented'.

What if we didn't find any number that is lower than its right neighbor?
In that case, all numbers are ordered, highest first. This must be the last permutation possible. Which means that the next permutation will restart from the beginning of the cycle of all permutations.
In the first permutation, the numbers are ordered lowest first. To get there, we can just reverse that highest permutation sequence of numbers, and we can return that as the result.

If that's not the case, and we do have found a number that can be 'incremented', we need to find the next higher number to replace this number with.
We only look in the right part of the permutation, because using any number from further left would change the order more than we want.
We are looking for the lowest possible number that still is higher than our number.

Once we have found that replacement number, we exchange the two numbers.
We then have 'increased' our number by the next possible higher value of all permutations of the right part. At the same time, we have decreased the replacement number to the next possible lower number. So the ordering of the right part thus still is 'highest to lowest'. As we need the 'first' permutation of the right part, we can just reverse this.

That's it! We have found the lowest possible increment.

Again, I have left the comments in the code for easier following.

use v5.36;

sub next_permutation( @ints ) {
    return @ints
        if @ints <= 1;

    # Starting from the end, find the first number
    # that is lower than the one following it.
    my $index = $#ints;
    while( $index > 0 && $ints[ --$index ] gt $ints[ $index + 1 ] ) {
        # Everything is in the loop condition.
    }

    # No lower number found?
    # Then we are at the end of the permutations.
    return reverse @ints
        if $index == 0;

    my $value = $ints[$index];

    # Find the next highest value within the right part,
    # for using it to replace the current value.
    # (Remember that maybe not all values in the right part are higher!)
    # It has to be higher than the one to substitute, but the
    # lowest possible one.
    my ( $index_2, $replacement ) = ( $index + 1, $ints[ $index + 1 ] );
    for ( $index_2 + 1 .. $#ints ) {
        ( $index_2, $replacement ) = ( $_, $ints[$_] )
            if $value lt $ints[$_] lt $replacement;
    }

    # Swap the two numbers.
    @ints[ $index, $index_2 ] = @ints[ $index_2, $index ];

    # We know that the right side is sorted, highest first.
    # to have it sorted lowest first, we just need to reverse it.
    @ints[ $index + 1 .. $#ints ] =
        reverse @ints[ $index + 1 .. $#ints ];

    return @ints;
}

If we run this several times in a row, we will get a 'consecutive sequence of permutations'.
How nice for the title of this blog, combining the two tasks!

Thank you for the challenge!

Find the complete source code for both tasks, including tests, on Github.

(dxxi) 9 great CPAN modules released last week

Niceperl

Published by Unknown on Sunday 10 November 2024 00:55

Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12.

  1. Catalyst::Runtime - The Catalyst Framework Runtime
    • Version: 5.90132 on 2024-11-08, with 155 votes
    • Previous CPAN version: 5.90131 was 1 year, 3 months, 19 days before
    • Author: JJNAPIORK
  2. DBIx::Class::Helpers - Simplify the common case stuff for DBIx::Class.
    • Version: 2.037000 on 2024-11-08, with 48 votes
    • Previous CPAN version: 2.036000 was 4 years, 7 months, 11 days before
    • Author: WESM
  3. Firefox::Marionette - Automate the Firefox browser with the Marionette protocol
    • Version: 1.62 on 2024-11-03, with 16 votes
    • Previous CPAN version: 1.61 was 16 days before
    • Author: DDICK
  4. Getopt::Long::Descriptive - Getopt::Long, but simpler and more powerful
    • Version: 0.115 on 2024-11-07, with 58 votes
    • Previous CPAN version: 0.114 was 9 months, 18 days before
    • Author: RJBS
  5. Net::DNS - Perl Interface to the Domain Name System
    • Version: 1.48 on 2024-11-08, with 27 votes
    • Previous CPAN version: 1.47 was 1 month, 20 days before
    • Author: NLNETLABS
  6. PDL - Perl Data Language
    • Version: 2.095 on 2024-11-04, with 57 votes
    • Previous CPAN version: 2.094 was 2 days before
    • Author: ETJ
  7. Rex - the friendly automation framework
    • Version: 1.15.0 on 2024-11-05, with 86 votes
    • Previous CPAN version: 1.14.3 was 1 year, 3 months before
    • Author: FERKI
  8. SPVM - The SPVM Language
    • Version: 0.990029 on 2024-11-07, with 33 votes
    • Previous CPAN version: 0.990026 was 6 days before
    • Author: KIMOTO
  9. URI - Uniform Resource Identifiers (absolute and relative)
    • Version: 5.31 on 2024-11-06, with 118 votes
    • Previous CPAN version: 5.29 was 2 months, 1 day before
    • Author: OALDERS

(dxcii) metacpan weekly report - Scalar::List::Utils

Niceperl

Published by Unknown on Sunday 10 November 2024 00:54

This is the weekly favourites list of CPAN distributions. Votes count: 121

Week's winners (+4): Scalar::List::Utils 

Build date: 2024/11/09 23:47:36 GMT


Clicked for first time:


Increasing its reputation:

Dancer2 Documentation Grant Report

Perl Foundation News

Published by Saif Ahmed on Friday 08 November 2024 11:36


Jason aka CROMEDOME has submitted a midway report of his Dancer 2 Documentation project. While the project is undoubtedly an important piece of work, his report is also a perfect example of how grants (or indeed any project) should be done. There is a professional demonstration of discipline, identifying goals, challenges, and successes. He has submitted multiple reports through the term, each of which are transparent and reassuring, and I have posted these below.


First Meeting:

  1. Goals and Audience Alignment We started by aligning the grant goals with the proposal, ensuring a clear understanding of the target audience. My primary aim is to improve the documentation quality, making it more accessible and comprehensive for both new and experienced Dancer2 users.

  2. Documentation Review I reviewed the current documentation to identify areas needing updates and improvements. This step helps me focus on specific issues rather than just broad goals. Key areas of focus include:

    • Clarifying core concepts
    • Enhancing examples and tutorials
    • Updating deprecated methods and practices
    • Improving the structure for better readability

We've aligned on these key areas of focus.

  1. Approach and Strategy We discussed the approach for tackling the documentation updates. Specific details include:
    • Using story-driven analogies to explain concepts
    • Implementing task-oriented sections for better usability
    • Ensuring that explanations cater to different levels of user expertise

I will research these ideas to decide what tone and style the documentation will reflect.

  1. Critical Details and Use-Cases We compiled a list of details and specific use cases to cover in the new documentation. These include:

    • Simple "Hello, World!" applications
    • Detailed route handling examples
    • Advanced features like sessions and error handling
    • Real-world scenarios and best practices
  2. Meeting Schedule and Reporting We established a regular meeting schedule to ensure consistent progress tracking. Meetings will be held as follows:

    • Syncing meetings: Once a month with a weekly hold and room for ad-hoc meetings and updates over email
    • Progress reports: First week of every month

This schedule will help us maintain momentum and address any issues promptly.

  1. Immediate Next Steps We outlined the immediate next steps for the documentation work:
    • Determine the tone and style of the documentation
    • Draft introduction and installation sections using the chosen tone and style

Dancer2 Documentation Grant Report for July, 2024

_ Stated Goals_

The goal for month 1 was to work on the core of the Dancer2 documentation, Dancer2::Manual.

Work Accomplished

I spent some time up front talking with my grant manager (Sawyer X) working out a plan of attack and revisiting the planned schedule for the grant. Some things needed to be decided up front: what's the tone of this going to be? How best do we communicate information to users of Dancer2? How do we organize the mess of information that is the current manual in a more coherent way?

A printed manual has multiple chapters/sections to it; larger manuals may span several volumes. I moved any current documentation that clearly is part of the manual to the Dancer2::Manual:: namespace. I then gave each section a clearer purpose (abstract) so someone looking at Dancer2 on MetaCPAN has a better idea of what's in each document. I also revised the documentation map in Dancer2.pm to make clearer what is in each section of the manual.

For a theme, I decided to take a friendly and somewhat humorous approach, which matches the demeanor of most of the Dancer Core Team.

The order of sections in Dancer2::Manual is being reorganized so concepts presented in the manual build on those previously introduced. Each section explains a new concept and what it is used for, shows a commented example of that concept, then explains the why behind that example - why is it necessary, and why is it done that way.

Core concepts in Dancer2 have been explained in the new manual, and a rewritten approach to routes and route handlers is mostly complete.

Up Next

Continued work on the core of the manual. With the first section close to completion, a jump on other sections, and the new format for the layout close to completion, I should be able to focus on producing content for the month of August.

Dancer2 Documentation Grant Report for August 2024

Stated Goals

The goal for month 2 was to work on the core of the Dancer2 documentation, Dancer2::Manual.

Work Accomplished

The reorganization of content in the manual itself (along with the deployment guide) is complete. Work on content continued into templates and sessions, and some advanced content at the end of the manual has been completed.

I worked with my grant manager, Sawyer, to come up with a set of benchmarks to help us determine what done looks like. This will help me to better identify where effort is still needed, and when I can stop working on other sections.

I’m about 2-2.5 weeks behind where I wanted to be at this point. In the grant application, I asked for half a payment at the halfway point, and the remainder upon completion. I feel I need to complete the month 2 goals in their entirety before I should ask, so we will revisit this topic in the September report (I’ll send in early October).

Up Next

Immediate goals consist of catching up on where I want to be in the core manual. After that, I plan to tackle the Deployment Guide and other anscilary documentation.

Dancer2 Documentation Grant Report for October 2024

Stated Goals

Month 3: Example application; review and edit Dancer2::Manual Month 4: Update and revise the cookbook, deployment, and migration guides; final edits

Work Accomplished

Unexpected personal commitments and a recent hurricane impacting my area have led to delays, and the work is now approximately two months behind schedule. Despite these challenges, I have made solid progress and am actively resolving each area as I move forward.

The Manual is essentially complete, pending final reviews before it can be considered finished. Additionally, a new section, Dancer2::Manual::Extending, has been added. This guide covers extension topics, a logical addition that emerged as I wrapped up work on the core manual. The benefit is added readability for users and not having an overwhelming Manual. It is also complete but pending review before it's considered finished.

The cookbook is currently under review, and work is ongoing to define the structure and content of the tutorial. Dancer has a history of difficulties with the Tutorial and we decided to scope it well before I begin the work on it, to maintain clarity for users and focus for my work.

Up Next

After reviewing the remaining work with Sawyer last week, we’ve made adjustments to the schedule. The tutorial, which we expect to be a substantial piece, will be completed at the end to ensure it receives the appropriate focus. We’ve prioritized other items to facilitate timely completion of all areas. The remaining tasks are as follows:

  • Finalize the Cookbook (expected to complete quickly)
  • Review and revise the Deployment Guide
  • Review and revise the Keyword Guide (expected to complete quickly)
  • Publish the above for public review
  • Write the tutorial
  • Process feedback from public review and incorporate relevant changes

You can follow ongoing progress at https://github.com/PerlDancer/Dancer2/tree/docs/doc-rewrite-grant

This week in PSC (167) | 2024-11-07

blogs.perl.org

Published by Perl Steering Council on Friday 08 November 2024 06:07

The three of us attended another long meeting:

  • We continued refining our plan for TLS in core. We will collect feedback on its feasibility from the maintainers of the relevant modules.
  • We reviewed the status of putting the apostrophe package separator behind a feature and approved the PR.
  • We confirmed that we want to deprecate smartmatch with a feature. This effectively means that we don’t plan for a “better smartmatch” at this time (but it can still be pursued in future, by way of the air gap strategy, if there is appetite). We will file an issue for this.
  • We agreed that “negative” features (rather than outright removal) is our preferred way to deprecate historical Perl quirks as the language continues to evolve.
  • We discussed our ongoing inadequacy at dealing with maintenance releases. We wrote down next steps to get back on track, and also started looking into capturing a checklist to document the process.

[P5P posting of this summary]

Multiple Inheritance vs Role

blogs.perl.org

Published by Mohammad Sajid Anwar on Thursday 07 November 2024 21:44

I wish Mojo::UserAgent could be made to not visit private IPs

blogs.perl.org

Published by karjala on Thursday 07 November 2024 16:06

Someone wanting to make a social media site (such as a Mastodon server & web client for example) will want to allow its users to post URLs, for which previews will be shown in their posts.

These posts will be visited by a UserAgent, but there is the risk that a private IP (disguised as a FQDN hostname that resolves to it) will be in the URL's host, and that might cause security issues.

I could use LWP::ParanoidAgent, but then I'd have to fork a process to make the whole thing async, like a good Mojolicious site will be, and too many processes running can be a problem. Also I'd be missing on the many Roles that exist for Mojo::Useragent.

So I opened this issue on Mojolicious's github wishing for a solution.

London Perl & Raku Workshop 2024: Recordings & Thoughts

blogs.perl.org

Published by London Perl Workshop on Thursday 07 November 2024 13:02

Recordings of all talks from this year's London Perl & Raku Workshop are now available on YouTube: https://www.youtube.com/playlist?list=PLxNdCz2kBhVlzbVFcjwY6GkQf4zBhvwFn.

The sound quality of the recordings is not fantastic. We had some sort of issue that I've tried to fix in post. However, the auto generated captions by YouTube tend to be pretty good these days, so enable those if you have any problems understanding the speaker.

I go into the details a bit more about this in a personal blog post about the event, and how much effort is involved in trying to create the recordings, amongst other things.

Thanks to this year's sponsors, without whom LPW would not have happened:

(dxx) 11 great CPAN modules released last week

Niceperl

Published by Unknown on Saturday 02 November 2024 21:32

Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12.

  1. Alien::Build - Build external dependencies for use in CPAN
    • Version: 2.84 on 2024-10-29, with 22 votes
    • Previous CPAN version: 2.83 was 4 months, 24 days before
    • Author: PLICEASE
  2. App::cpanminus - get, unpack, build and install modules from CPAN
    • Version: 1.7048 on 2024-10-29, with 281 votes
    • Previous CPAN version: 1.7047 was 1 year, 2 months, 30 days before
    • Author: MIYAGAWA
  3. App::DBBrowser - Browse SQLite/MySQL/PostgreSQL databases and their tables interactively.
    • Version: 2.416 on 2024-10-28, with 14 votes
    • Previous CPAN version: 2.415 was 1 month, 23 days before
    • Author: KUERBIS
  4. App::Netdisco - An open source web-based network management tool.
    • Version: 2.080003 on 2024-10-30, with 16 votes
    • Previous CPAN version: 2.079001 was 1 month, 17 days before
    • Author: OLIVER
  5. DBIx::Class::Candy - Sugar for your favorite ORM, DBIx::Class
    • Version: 0.005004 on 2024-10-29, with 21 votes
    • Previous CPAN version: 0.005003 was 7 years, 3 months, 15 days before
    • Author: WESM
  6. DBIx::Lite - Chained and minimal ORM
    • Version: 0.36 on 2024-10-31, with 28 votes
    • Previous CPAN version: 0.35 was 1 month, 13 days before
    • Author: AAR
  7. Image::ExifTool - Read and write meta information
    • Version: 13.00 on 2024-10-29, with 42 votes
    • Previous CPAN version: 12.76 was 8 months, 29 days before
    • Author: EXIFTOOL
  8. PDL - Perl Data Language
    • Version: 2.094 on 2024-11-02, with 57 votes
    • Previous CPAN version: 2.093 was 1 month, 3 days before
    • Author: ETJ
  9. SPVM - The SPVM Language
    • Version: 0.990026 on 2024-11-01, with 33 votes
    • Previous CPAN version: 0.990025001 was 7 days before
    • Author: KIMOTO
  10. Sys::Virt - libvirt Perl API
    • Version: v10.9.0 on 2024-11-01, with 17 votes
    • Previous CPAN version: v10.6.0 was 2 months, 26 days before
    • Author: DANBERR
  11. Term::Choose - Choose items from a list interactively.
    • Version: 1.767 on 2024-10-28, with 15 votes
    • Previous CPAN version: 1.765 was 5 months, 26 days before
    • Author: KUERBIS

Advertising Perl

Perl Hacks

Published by Dave Cross on Friday 01 November 2024 15:10

Last weekend, we had a very successful (and very enjoyable) London Perl Workshop. After a five-year break, it was great to see so many old faces again. But in addition to people who had been regular attendees at recent workshops, two other groups of people were there in large numbers—people who had moved away from the Perl community (and who were coming back for the nostalgia) and new Perl users who hadn’t been to any Perl conference before. In both cases, it seems that one marketing move was particularly effective at telling both of these groups about the workshop.

It was a small, text advert that ran on MetaCPAN.

I had nothing to do with the organisation of the workshop, so I have no idea who had the idea of running that ad, but it was (like so many great ideas) obvious in retrospect. It’s great to publish blog posts about upcoming events and mention events in the Perl Weekly newsletter. But marketing like that is mostly going to be read by people who are already part of the Perl community. And they (hopefully) already know about the workshop.

Whereas, sites like MetaCPAN are visited by Perl programmers who don’t consider themselves part of the community. People who don’t attend Perl Mongers meetings. People who don’t read blogs.perl.org. People who are (to use terminology that has been used to explain this problem for about twenty years) outside the echo chamber.

Advertising Perl community events to as large an audience as possible is a really good idea, and I think we should do more of it. But it has its downsides. Someone has to do some work to create a pull request to add the advert (and another one to remove it once the event is over). That’s not hard, but it requires thought and planning. I started to wonder if we could simplify this process and, in doing so, encourage more people to run ads like these on sites where more people might see them.

After an hour or so, I had a prototype of the Perl Ad Server – which I have subsequently cleaned up and improved.

It’s a simple enough concept. You add a tiny fragment of Javascript to your website. And that then automatically adds a small banner ad to the top of your site. We can control the ads that are being promoted by simply editing the JSON that we serve to the client sites.

It’s experimental. So I’d like to get as many people as possible to try it out.

It comes with a tiny caveat. I’m neither a web designer nor a Javascript expert. So it may interact with some web frameworks in weird ways (I added it to CPAN Dashboard and the ad appeared under the navbar – which isn’t supposed to happen). If it doesn’t work with your site for some reason, please remove the Javascript and raise an issue so I can investigate.

And if you’d like your event added to the current list of ads, let me know too.

The post Advertising Perl appeared first on Perl Hacks.

Known for its agility and simplicity, the Mojolicious framework is especially valued in niche industries with a Perl heritage. In our…

(dxix) 10 great CPAN modules released last week

Niceperl

Published by Unknown on Sunday 27 October 2024 00:06

Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12.

  1. DBIx::Connector - Fast, safe DBI connection and transaction management
    • Version: 0.60 on 2024-10-20, with 47 votes
    • Previous CPAN version: 0.56 was 8 years, 7 months, 4 days before
    • Author: ARISTOTLE
  2. Excel::Writer::XLSX - Create a new file in the Excel 2007+ XLSX format.
    • Version: 1.14 on 2024-10-21, with 64 votes
    • Previous CPAN version: 1.13 was 8 days before
    • Author: JMCNAMARA
  3. Future - represent an operation awaiting completion
    • Version: 0.51 on 2024-10-21, with 57 votes
    • Previous CPAN version: 0.50 was 1 year, 7 months, 4 days before
    • Author: PEVANS
  4. Module::CoreList - what modules shipped with versions of perl
    • Version: 5.20241020 on 2024-10-20, with 43 votes
    • Previous CPAN version: 5.20240920 was 1 month before
    • Author: BINGOS
  5. Module::Pluggable - automatically give your module the ability to have plugins
    • Version: 6.2 on 2024-10-25, with 25 votes
    • Previous CPAN version: 5.2 was 9 years, 2 months, 20 days before
    • Author: SIMONW
  6. Perl::Critic - Critique Perl source code for best-practices.
    • Version: 1.156 on 2024-10-23, with 131 votes
    • Previous CPAN version: 1.152 was 1 year, 6 days before
    • Author: PETDANCE
  7. Rose::DB::Object - Extensible, high performance object-relational mapper (ORM).
    • Version: 0.821 on 2024-10-20, with 21 votes
    • Previous CPAN version: 0.820 was 3 years, 3 months, 24 days before
    • Author: JSIRACUSA
  8. SPVM - The SPVM Language
    • Version: 0.990025001 on 2024-10-25, with 33 votes
    • Previous CPAN version: 0.990023 was 7 days before
    • Author: KIMOTO
  9. Text::MultiMarkdown - Convert MultiMarkdown syntax to (X)HTML
    • Version: 1.003 on 2024-10-24, with 13 votes
    • Previous CPAN version: 1.002 was 11 months, 24 days before
    • Author: BRIANDFOY
  10. XML::Compile - Compilation based XML processing
    • Version: 1.64 on 2024-10-21, with 14 votes
    • Previous CPAN version: 1.63 was 5 years, 3 months, 19 days before
    • Author: MARKOV

What Languages Do I Use?

Perl on Medium

Published by Khun Yee Fung, Ph.D. on Sunday 20 October 2024 22:54

I have a simple way to decide whether I will use Ruby, Perl, Java, or Bash. If I need to maintain it 10 years from now. It is in Java. If…