If you've discovered something amazing about Perl that you just need to share with everyone, this is the right place.

This section is also used for non-question discussions about Perl, and for any discussions that are not specifically programming related. For example, if you want to share or discuss opinions on hacker culture, the job market, or Perl 6 development, this is the place. (Note, however, that discussions about the PerlMonks web site belong in PerlMonks Discussion.)

Meditations is sometimes used as a sounding-board — a place to post initial drafts of perl tutorials, code modules, book reviews, articles, quizzes, etc. — so that the author can benefit from the collective insight of the monks before publishing the finished item to its proper place (be it Tutorials, Cool Uses for Perl, Reviews, or whatever). If you do this, it is generally considered appropriate to prefix your node title with "RFC:" (for "request for comments").

User Meditations
Challenge: Ricochet Robots
6 direct replies — Read more / Contribute
by LanX
on Feb 18, 2021 at 11:16
    Ricochet Robots is a board game about optimizing moves. (see wikipedia description)

    The 4 pieces represent the "robots" Blue, Yellow, Red and Green on a board with 16x16 cells and some walls.

    Rules: Each round one of the robots can be moved horizontally or vertically, and does not stop until it reaches an obstacle - either a wall or another robot.

    E.G. in this example the Yellow on B14 can only reach A14 or B16 in one move, and nothing in between. You can only move one robot per round.

    The object of the game is to bring one specific robot to an indicated target (here C9 marked with * ) using as few moves as possible.

    (Since the goal has no neighboring wall you'll need to position other robots as obstacles nearby to reach it)

    A B C D E F G H I J K L M N O P --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 1| | R | |1 . .---. . . . . . . . . . . .---. . 2| | | |2 . . . . . . . . . . . . . . . . 3| | |3 . . . . . . . . . . .---. . . . . 4| | |4 . . . . . .---. . . . . . . . .---. 5| |5 ---. . . .---. . . . . . . . . . . . 6| | |6 . . . . . . . . . . . . . . . . 7| | | |7 .---. . . . . .---.---. .---. . .---. . . 8| | | | |8 . . . . . . . . . . . . . . . . 9| * | | |9 . . . . . . .---.---. . . .---. . . . 10| | B | |10 . . . .---. .---. . . . . . . . .---. 11| | |11 ---. . . . . . . . . . . . . . . . 12| |12 . . . . . . .---. .---. . . . . . . 13| | | |13 .---. . . . . . . . . . . . . . . 14| (Y)| | |14 . . . . . . . . . . . . . .---. . 15| | | |15 . . .---. . . . . . . .---. . . . . 16| | G | |16 --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- A B C D E F G H I J K L M N O P

    • Whats the shortest solution (in number of rounds) to bring Yellow on target? Please display the moves for each round at the end.
    Provide a runnable Perl script solving it in under 15 min on a current home PC.

    Bonus question:

    If you are still bored...

    • How many rounds do you need at most to reach any field?
    • How many rounds to you need if the goal has to be reached by any of the robots, like the Blue?

    I do have a script I wrote 16 years ago.

    It needed over an hour back than and runs today in 1:30 min on my laptop, so it's solvable within the given margin. :)

    But it took me two days to write it, and you might run into memory problems.


    I had a lot back then, and learned a lot. Hope you too ... :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery


    added some clarifications and links


    here the positions of the walls (yes strings as non-strict barewords, this script is old)

    @vwalls=(A5,A11,B7,B13,C1,D15,E5,E10,G4,G10,H7,H9,H12,I7,I9,J12,K7,L3, +L15,M9,N7,O1,O14,P4,P10); # below cell @hwalls=(B2,B7,B14,D10,D15,E1,E6,E16,F4,F11,G8,G9,H13,I8,I9,I13,J1,K3, +K8,L15,M10,N2,N7,N14,N16); # to the right $Target="C9"; $Y="B14"; $R="J1"; $G="F16"; $B="M10";


    It's specifically requested to bring Yellow on target, the first version was misleading, sorry.

  • removed (updated) marker in title again, to avoid "inheritance" to replies
[OT] Brendan Eich interview
1 direct reply — Read more / Contribute
by tangent
on Feb 15, 2021 at 18:07
    I found this interview very interesting - Brendan Eich: JavaScript, Firefox, Mozilla, and Brave | Lex Fridman Podcast. It is 3 hours long but the time just flew by. An insider's view on the whole history of web technologies, with a little bit of politics thrown in every now and then.

Brute force vs algorithm (PWC # 100)
8 direct replies — Read more / Contribute
by 1nickt
on Feb 15, 2021 at 13:06

    Hello beloved brethren,

    I don't usually participate in the Perl Weekly Challenge but for the occasion of the 100th challenge I thought I'd give it a try.

    The challenge

    You are given triangle array. Write a script to find the minimum path sum from top to bottom.

    When you are on index i on the current row then you may move to either index i or index i + 1 on the next row. Example:

    Input: Triangle = [ [1], [2,4], [6,4,9], [5,1,7,2] ] Output: 8 Explanation: The given triangle 1 2 4 6 4 9 5 1 7 2 The minimum path sum from top to bottom: 1 + 2 + 4 + 1 = 8 [1] [2] 4 6 [4] 9 5 [1] 7 2


    More complex than it first seems, this task requires the programmer to look ahead further than the "next move" to see which "move" is correct. I think the solution involves some sort of recursive algorithm but I cannot see how one could avoid computing all possible paths. It's not possible to assume that the lower of the two choices for "next move" is the correct move, as it may lead to a subsequent choice of two very high numbers.

    I eagerly await minds brighter than mine to provide "correct" ways of doing this. In the meantime here's my brute-force approach which works well, given that the spec is for a four-row triangle:

    # PWC 100 use strict; use warnings; use feature 'say'; use JSON::PP; use Test::More; while ( my $line = <DATA> ) { my ($json, $expected) = split /\s/, $line; my $aoa = decode_json($json); is( compute($aoa), $expected ); } sub compute { my @aoa = @{shift()}; my $total; for my $r1_ix (0,1) { # second row for my $r2_ix ($r1_ix, $r1_ix+1) { # third row for my $r3_ix ($r2_ix, $r2_ix+1) { # fourth row my $sum = $aoa[0][0] + $aoa[1][$r1_ix] + $aoa[2][$r2_ix] + $aoa[3][$r3_ix]; say sprintf('Sum of %d (%d, %d, %d, %d)', $sum, $aoa[0][0], $aoa[1][$r1_ix], $aoa[2] +[$r2_ix], $aoa[3][$r3_ix]); $total = $sum if ! $total || $total > $sum; } } } return $total; } done_testing; __DATA__ [[1],[2,4],[6,4,9],[5,1,7,2]] 8 [[9],[1,6],[7,8,2],[5,8,2,3]] 19

    Here's to a lively discussion!

    The way forward always starts with a minimal test.
Using MinGW to build perl on windows forcing it to expand * into glob in cmd.exe
3 direct replies — Read more / Contribute
by Discipulus
on Feb 14, 2021 at 11:01
    Hello folks,


    A recent post evidentiated a bug in some raku builds for windows: if compiled using MinGW (instead of compiled with MS tools as rakubrew uses) an unexpected expansion of * into a glob happens in cmd.exe prompt. The thread born because Athanasius found impossible to escape this * in cmd.exe (more on this later on).

    Contributions to the above threads highlighted a fact unkonwn to me: there is a tiny layer, the C runtime library, responsible to find argc and build argv to pass to main (see jcb's answer). The actual C runtime library depends on the tool used to build perl (or raku). At least this is what I understood.

    While the above is interesting per se triggered another question in my mind: if a raku built using MinGW unintentionally expands * there must be a way to build a perl that expands too * into a glob. You will see later on why this is a futile question, but: futile, complex and hackish is exactly the kind of task I love.

    -Prepare the ground-

    To build this new frankestein perl we need: a recent strawberry portable edition: strawberry-perl- is what I used. Extract this wherever you want: in the following examples I will use C:\ulisse\perl5.32-64bit

    Then we need to download perl-5.32.1.tar.gz.

    Finally make an empty dir to use as playground. Open the folder where you extracted the strawberry portable edition and launch the portableshell.bat then in the prompt window execute (adjust to your needs):

    ---------------------------------------------- Welcome to Strawberry Perl Portable Edition! * URL - * see README.TXT for more info ---------------------------------------------- Perl executable: C:\ulisse\perl5.32-64bit\perl\bin\perl.exe Perl version : 5.32.1 / MSWin32-x64-multi-thread C:\ulisse\perl5.32-64bit>x: X:\>mkdir globperl X:\>cd globperl X:\globperl>

    Then just to be sure nothing in PATH will interfere with our experiments clean up the PATH as much as possible, leaving only strawberry directories and windows system ones (adjust to your needs):

    X:\globperl>set PATH=C:\ulisse\perl5.32-64bit\perl\site\bin;C:\ulisse\ +perl5.32-64bit\perl\bin;C:\ulisse\perl5.32-64bit\c\bin;C:\Windows\sys +tem32;C:\Windows;

    Finally extract the source of perl downloaded from CPAN, perl-5.32.1.tar.gz to X:\globperl\perl-5.32.1

    -Modify the source code-

    Browse the folder X:\globperl\perl-5.32.1\win32 and edit the win32.c file, in my case around line 73 and change:

    #ifdef __GNUC__ /* Mingw32 defaults to globing command line * So we turn it off like this: */ int _CRT_glob = 0; #endif

    the relevant line into int _CRT_glob = 1; save and close the file.

    In the same folder edit the runperl.c file around line 19 in my case putting again int _CRT_glob = 1; and so resulting in:

    #ifndef PERLDLL int _CRT_glob = 1; #endif

    Save and close.

    -Compile it-

    In the above portableshell.bat window move to the cd X:\globperl\perl-5.32.1\win32 directory where win32 perl source is. Now we have to instruct gmake ( which will use GNUmakefile inside win32 folder while Makefile and are used by other flavours of make) to install our new perl inside a custom dir. We can modify the GNUmakefile (around lines 49 and 50) to use different INST_DRV and INST_TOP or we can feed this parameter from command line.

    So we are ready to build and install our new perl:

    X:\globperl\perl-5.32.1\win32> gmake INST_DRV=x: INST_TOP=X:\globperl\ +my_perl # CCTYPE=GCC # GCCBIN=gcc # GCCVER=8.3.0 # GCCTARGET=x86_64-w64-mingw32 # GCCCROSS= # WIN64=define # ARCHITECTURE=x64 # ARCHNAME=MSWin32-x64-multi-thread # MAKE=gmake [...] X:\globperl\perl-5.32.1\win32> gmake install [...]

    -First test and dll hell-

    This shouldnt happen but as happened to me can also happens to you. Open a new command prompt ( not a portableshell.bat but a regular plain cmd.exe prompt). I erase completely PATH to be sure nothing will interefere, then I tried to invoke our brand new perl

    C:\Users\io>set PATH= C:\Users\io>x:\globperl\my_perl\bin\perl.exe -v

    A nasty error window pops up complaining libgcc_s_seh-1.dll is missing. It is present in the C:\ulisse\perl5.32-64bit\perl\bin strawberry folder and should be available during building, but we can copy in our brand new perl\bin directory to overcome the error, but then another error pops up about missing libwinpthread-1.dll and then again about libstdc++-6.dll so we copy these missing dlls and finally we got a sane perl.exe

    C:\Users\io>copy c:\ulisse\perl5.32-64bit\perl\bin\libgcc_s_seh-1.dll +x:\globperl\my_perl\bin 1 file copied. C:\Users\io>copy c:\ulisse\perl5.32-64bit\perl\bin\libwinpthread-1.dll + x:\globperl\my_perl\bin 1 file copied. C:\Users\io>copy "c:\ulisse\perl5.32-64bit\perl\bin\libstdc++-6.dll" x +:\globperl\my_perl\bin 1 file copied. C:\Users\io>x:\globperl\my_perl\bin\perl.exe -v This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x +64-multi-thread Copyright 1987-2021, Larry Wall


    Sometimes the dll hell can be even worst and the sybilline The application was unable to start ... 0x000007b error appears: in this case you can profit of the wonderful program Dependencies to dipanate the dll hell.

    -Fire proof-

    Now let's look if our new perl is able to expand * into glob on cmd.exe as we wanted to prove:

    X:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" * corelist.bat cpan.bat enc2xs.bat encguess.bat h2ph.bat h2xs.bat instmo +dsh.bat json_pp.bat libgcc_s_seh-1.dll libnetcfg.b at libstdc++-6.dll libwinpthread-1.dll perl.exe perl5.32.1.exe perl532 +.dll perlbug.bat perldoc.bat perlivp.bat perlthank s.bat piconv.bat pl2pm.bat pod2html.bat pod2man.bat pod2text.bat pod2u +sage.bat podchecker.bat prove.bat ptar.bat ptardif f.bat ptargrep.bat shasum.bat splain.bat xsubpp.bat zipdetails.bat

    Tadąaaa! :)

    -Why not?-

    Now we have a perl expanding * into a glob, but... what if we need to pass a regex? Oh well we can escape an eventual * you'd say. No: this * is impossible to escape!

    cd x:\globperl x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" * my_perl perl-5.32.1 x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" "*" my_perl perl-5.32.1 x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" ^* my_perl perl-5.32.1 x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" '*' '*' x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" "^*" ^* # this is really fun! It globs the root of the current drive x: # Infact in windows each drive letter has its own root: \ x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" \* \$RECYCLE.BIN \globperl x:\globperl\my_perl\bin\perl -e "print join ' ', @ARGV" \\* \\*

    No way. It is because of this that Athanasius spotted a bug in the above mentioned post

    -Acknowledgements and useful reads-

    Thanks to Athanasius, jcb and sortiz (who supported me also in the #raku irc channel) for their contributions to the raku post.

    I got an invaluable and patient help from a wise one in the #perl freenode irc channel who pointed me to the relevant source code modifications needed and helped me to escape from dll hell.

    They also explained me that glob expansion is disabled by default because MinGW used to enable it by default, but now while mingw-w64 crt defaults to disabled globbing, mingw-builds scripts, which is what most people use to build mingw, instead of doing that manually, do enable glob expansion by default.

    There are other discrepancies: while in mingw-w64 _CRT_glob is a boolean in it's a bitfield.. so good luck.

    See mingw-w64-headers/crt/ and confront with (search for: "* Manifest definitions for flags to control globbing of the command line").

    Also an interesting page about escaping in cmd.exe and a SO answer and dont miss everyone-quotes-command-line-arguments-the-wrong-way ( the last one added 2021-02-15, found here)

    Nice, no?


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Renaming all files in a directory
5 direct replies — Read more / Contribute
by Aldebaran
on Feb 01, 2021 at 22:17

    I'm so relieved to be back at my keyboard, with a roof over my head, fridge full of food, and plentiful water of varied temperature. I was feeling kind of stuck because I had a repository that I had downloaded that didn't have the proper credentials, and it was preventing updating. I got that all cleared away, so now I have:

    $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal $

    One of the first things I'll do is create a webpage describing the trip, and that is going to require that a bunch of odd images gets herded to the net, with an exact number of corresponding captions. For this task, I find that I can really economize on GUI events with perl and a little skill on the command line.

    But I'm one of those guys who would make every mistake in the book if I started at square one. I know that I had a thread some time back called renaming all files in a directory. I tried to search for this with keywords but had to resort to scrolling through my writeups back to 2012. I was gonna complain that the search didn't work. However, I had searched for the word 'rename' not 'renaming', and I realize that the problem is not with the software.

    I tried one of the answers I hadn't used before:

    ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter"." +.jpg"; +rename($old,$new);$counter++;' $

    That command didn't work at first, but I could get my way to one that did because what exists between single quotations is lexical perl that I understand. And gosh, I've been pretty diligent about studying this including taking in Util's talk at 2020 perl conference, which helped me understand how people "get there on the command line."

    $ ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter". +"jpg"; > +rename($old,$new);$counter++;' $ ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter". +".jpg"; +rename($old,$new);$counter++;' $

    and voila...

    $ pwd /home/hogan/6.scripts.personal/1.umatilla.1./template_stuff/aimages $ ls image0.jpg image12.jpg image15.jpg image3.jpg image6.jpg image9. +jpg image10.jpg image13.jpg image1.jpg image4.jpg image7.jpg image11.jpg image14.jpg image2.jpg image5.jpg image8.jpg $

    Another modification gets my captions looking all uniform, so I know I've got a bijection going:

    ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="caption"."$counter". +".txt"; +rename($old,$new);$counter++;'
    $ pwd /home/hogan/6.scripts.personal/1.umatilla.1./template_stuff/captions $ ls caption0.txt caption13.txt caption2.txt caption6.txt caption10.txt caption14.txt caption3.txt caption7.txt caption11.txt caption15.txt caption4.txt caption8.txt caption12.txt caption1.txt caption5.txt caption9.txt $

    Now I know that my data will be well-conditioned for use by other scripts to get it onto the net.

    This was just my day in having perl making something easier....

EU::MM recipes -- a lazy Makefile.PL for README and repository info
1 direct reply — Read more / Contribute
by Discipulus
on Jan 28, 2021 at 17:10
    Hello folks!

    I use module-starter to sketch up my modules and it defaults to good 'ol ExtUtils::MakeMaker which is a basic author tool and also an end user tool. After it many more featured authoring tools appeared on the perl scene and I have collected a bounch of useful links at the end of this post, for your pleasure. But...

    After asking and digging about let Makefile.PL to do the Readme file for me -- new target? I realized an extra target what not was I needed. To much work to remember to even call it. So I have investigated a bit about standard targets to see if I had the chance to hack some of them and the Makefile.PL iteself, treated as a normal perl program.

    My goals..

    I had two goals and they are reached with the below code: firstly I needed a way to generate my README file automatically from the pod section of the main module and secondly I want my eventual git repository added automatically to my META.yml and META.json files as explained in perlmaven article but in a lazier way.

    With the help you gave me and some important contribution given by the irc #perl channel I have now something working the way I like and that you can review in details below.

    ..and yours?

    I'm sure many of you have other interesting things to show as makefile recipes or makefile tricks as the wise monk pryrt shown in his Re: let Makefile.PL to do the Readme file for me -- new target? about his Win32::Mechanize::NotepadPlusPlus module.

    Here you have the basic Makefile.PL produced by module-starter with my modification clearly marked by big comments at start and end:

    Interesting resources:

    Other authoring tools (not complete list):

    Interesting readings:

    update 2021 Feb 08 I have added a check to ensure tabs are prepended to make recipe because spaces breaks everything.


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Terrifying Beauty
4 direct replies — Read more / Contribute
by eyepopslikeamosquito
on Jan 28, 2021 at 00:59
Rediscovering Hubris
4 direct replies — Read more / Contribute
by Leitz
on Jan 17, 2021 at 18:40

    A line from perlootut goes, "There's really no good reason to write your classes from scratch in Perl." I beg to differ. There are many reasons we come to Perl; often those reasons are unique to each individual. What brings the perlootut authors to Perl may not be the same as what brings any of us.

    Long ago, when the O'Reilly Perl book was much thinner and had a pink spine, hubris was a valued quality in a Perl programmer. Today many are shunned because they use "ancient" Perls, anything less than 5.30 is "EOL". Some of us have to live in the world that doesn't auto-upgrade Perl. We're told to get some collection of modules from CPAN, everything is already done for us. That's a wonderful idea, but it doesn't play out. Many modules depend on XS, or depends on something that depends on XS, yet not every compute node has a compiler. Or the CPAN module depends on something that requires a more recent version of Perl than what we are allowed to code for.

    I have actually been told that I should look for another job if work won't upgrade language "X" to a more "modern" version. No real reason, just "more modern". Hubris can have a negative incarnation.

    Hubris can help us move forward when the world seems against us. Outside of that one sentence, the perlootut is a wonderfully written and useful document. The perlobj page is also top of the line documentation. In hubris I try to code for Perl 5.8. Not because that version is any better than later versions, quite the contrary! The Perl maintainers do a great job of keeping the language moving forward. In hubris I create objects without Moose, Moo, or any other CPAN OOP module. My good reason is so that I better understand what is going on and how Perl objects work. In hubris, because I dislike the fragility that comes with unnecessary complexity, I seldom use CPAN modules.

    Despite my struggles with Perl, and the occasional (more than occasional) muttered curse onto whomever thought 27 layers of sigils is human readable, Perl is its own "killer feature". Solid Perl 5.8 code still works well. If you removed CPAN from the multiverse, Perl could still do more than most of us. Other (dang near all) languages are easier to learn. Some of them have much faster performance, or significantly more hits on job search boards. At the end of the day, though, if it can be done then you can probably do it in Perl.

    I currently work in Perl. To push my skills further, my personal projects (toys, really) are in Perl. Despite being a slow learner, and struggling every day, I honor my employer by doing my best. And that is my killer feature.

    Chronicler: The Domici War (

    General Ne'er-do-well (

For discussion: operator attributes - associativity, chainity and ability to short-circuit
2 direct replies — Read more / Contribute
by rsFalse
on Jan 13, 2021 at 15:47
    Perl 5.32 (year 2020) introduced a new ability of binary comparison operators. Now they can be chained! ( ).
    And perldoc describes this new usage in:

    There are some short-circuiting operators in Perl from before 5.32 version: &&, ||, //, and, or (not xor).

    What is difference between associativity and chainity?
    I suggest to distinguish these two attributes of operators as follows: associativity only sets a direction of operations; chainity sets an ability to 'communicate' between consecutive operators, in other words - a later operator can influence the behaviour of a former operator.

    Then I suggest to improve a table of Perl operators by introducing two more columns: chainity (ability to chain) and ability to short-circuit.
    This will help to newcomers and beginners! I have often used these tables of operators from perlcheat and from beginning of the perlop:, because it takes time to remember precedence and direction of associativity. Two new attributes in the table will be more usable than a searching of them through the whole long perlop document.
    In the current table of attributes I find only one column, which contains values: nonassoc, left, right, chained, chain/na. Chained implies associativity, but it lefts its direction undefined, e.g. in the line: "chained     < > <= >= lt gt le ge" newcomer doesn't know direction. We know - it is left-assoc.

    Perl is difficult to memorize and it has long learning curve because of its archaity and many many rules with many exceptions, which makes a life easier, but makes learning/memorizing - difficult. So tables/cheatsheets are useful to have near a hand. E.g. operators 'or' and 'xor' seem similar by their appearance and by their category (both are logical operators), but one has an ability to short-circuit and another - hasn't. This was a surprise for me. Upd.The surprise was not about short-circuit, but about returning last evaluated value.

    I can't test a new perl 5.32 now (upd. perlbrew isn't working /upd.*, and there are no online IDEs where I could find a new version: all use older versions, including WebPerl: which uses 5.28).
    But I hope that I will be correct when talking further about new abilities of comparison operators.

    So, first of all I guess that new version outputs different results for these two lines of codes:
    2 < 4 < 3 and ( 2 < 4 ) < 3. In the first example the chaining of operators occurs and in the second example - ordinary comparisons occurs. First outputs - 0/'', second - 1. Am I wrong? Here parentheses cut a chain of operators: one operator doesn't see another. If second behaves same as first then it would be backwards incompatible.

    Only some examples of chained comparisons: "1 < 3 <= 3 > 0 le 1 gt 0 ---> 1", "1 < 2 < ... < 9 ---> 1", "1 ne 2 ne 1 ---> 1".

    How can we describe a behaviour of chained comparison operators?
    I suggest the following way. If an operator "sees" another operator towards the direction of associativity (i.e. it is chained to it), then it changes it behaviour (btw. becomes overloaded) - it compares both operands and in case of TRUE returns right operand (once evaluated), and in case of FALSE - returns 0/''. This description allows the last operator to be not chained, so it will behave as usual comparison op (TRUE - 1, FALSE - 0/'').

    Chainity implies (requires) associativity, as ability to short-circuit does, but chaining does not imply an ability to short-circuit and vice versa, so I suggest to keep these two attributes separately. Maybe in a future perl such will occur.
    By the way, operators  &&, ||, //, and, or are short-circuiting, but they are not chained (i.e. we can put parentheses in left-assoc pattern to "blind" consecutive operators and result will not change).

    Also I have an idea (I don't believe that it is good, but I leave it here if someone wants to discuss). That: writer could choose by himself if he wants his operator to look to the next operator (i.e. to make a chain). One way could be to prepend '&' before an operator. So then $A &< $B &> $C < $D should work as a chain (note no '&' at the last operator).

    Once more about tables. From perlop it is unknown which 'equality' operators can be chained and which can not. This needs a clarification.

    Here I'll leave some links to older topics (by me), which can be somehow related to this one:
    Pls more operators, e.g. <&&=
    'xor' operator is not a sibling to 'or' and 'and'?

    Here is my suggestion of an expanded table (which is a bit incomplete, but I want to show an idea). Note that vertical lines mean that some operators are the same precedence but divided into separate lines:
    ASSOC. COND. SHORT-C. CHAINS OP. left terms and list operators (leftward +) left -> nonassoc ++ -- right ** right ! ~ \ and unary + and - left =~ !~ left * / % x left + - . left << >> nonassoc named unary operators LEFT no yes yes < > <= >= lt gt le ge | LEFT no yes yes == != eq ne ~~ | LEFT no no no <=> cmp nonassoc isa left & left | ^ left yes yes no && left yes yes no || // nonassoc .. ... right yes no no ?: right = += -= *= etc. goto last next red +o dump left , => nonassoc list operators (rightward) right not left yes yes no and | left yes yes no or | left no no no xor

    Upd. Also created a documentation issue asking to expand this table of attributes --

    (*upd. perlbrew failed to install from its download page, but later I found it in Software manager and installed.)
Is typeglob feature really useful?
4 direct replies — Read more / Contribute
by xiaoyafeng
on Jan 09, 2021 at 12:48

    As we all know, Perl support same name but different type, that means $foo and @foo could be both exist without any violation.

    This sounds a smart and nature feature, but from time to time, I suspect if it's useful. During my life, I've never defined 2 different type of variables with same name. Considering perl have to define a special(or maybe huge and complex ) data struct to store glob, if we discard this feature, maybe perl could be faster and simpler?

    Just a thought jump into my head, Please enlighten me. Thanks

    EDIT: modify title as LanX point out.

    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Diary of a Zydeco experiment - E04 - Renaming
No replies — Read more | Post response
by Smonff
on Jan 08, 2021 at 11:16

    This is the fourth episode, and after Diary of a Zydeco experiment - E03 - Errors for fun and success, I came back here to deliver some news. The project is not progressing much since I had to move recently and have to renovate a house. I never spent so much time away from my machine (how sad).

    Anyway I am seriously thinking about changing the namespace for the Art::World project and move it to the Acme:: namespace... This thing looks more and more like an experiment that will surely never be used by anybody except me and I see it humbly as an artwork by itself, but I guess it will be the final project. It's not like people would start to use it as a dependency. Or maybe only for showing examples of my bad coding practices.

    Since September 22nd, a small amount of tasks have been started:

    • switched the project to only one large module, trying to make it the Zydeco way,
    • moved the ideology documentation to a separate pod
    • added Underground, Space and Market roles
    • Nested playground and Place classes
    • Added Event, Opening, Sex, Collective, Magazine, Institution, Squat, Workshop, Website, Critic, Article, and Book classes
    • Applied Collector type constraints on class Artist and role Collectionable
    • Removed the Wildlife class since it is redundant with Art::World Agent
    • tobyink suggested the removal of duplicated attributes in nested classes
    • added a Fame role and moved the Agent reputation there
    • forced the Collector->collection to be composed of Artwork(s)
    • listed contributors of the project
    • created various Collector methods like sale() or acquire()
    • tried to use Type::Tiny more efficiently and upgrading to its last version that offered non quoted types constraints for attributes (see RT #133448)
    • adding a Makefile
    • introduced Conf::Tiny
    • added a minimal Meta toolkit
    • limited Perl version to > 5.24.0
    • Event is now a Role, not a Class because we do composition, not multiple inheritance
    • enabling the postderef feature everywhere because we are so MODERN
    Finally, it was quite a lot... Cant wait to rename to Acme::Art::World !

Happy 2021
2 direct replies — Read more / Contribute
by misterperl
on Jan 06, 2021 at 11:08
    I guess this isn't strictly a question but ....
    print "thank-you Monks!\n\n"
    for all of your excellent advice in 2020. I always have a bit of apprehension that people will think me a dummy, but in this land, thankfully, kindness abounds ! Your replies were most helpful.

    I wish you all a healthy and successful 2021 and may


    - Mr P

cpan: Terminal does not support AddHistory.
1 direct reply — Read more / Contribute
by kcott
on Jan 04, 2021 at 23:39

    I have been seeing the following, for the past 18 months, every time I use the cpan utility:

    $ cpan Terminal does not support AddHistory. To fix that, maybe try> install Term::ReadLine::Perl cpan shell -- CPAN exploration and modules installation (v2.28) Enter 'h' for help. cpan[1]>

    I looked into that briefly (and unsuccessfully) several times; in general, whatever I wanted to install via cpan was more important than AddHistory, which I only use infrequently anyway, so it ended up on my TODO list.

    I tried with the suggested module, Term::ReadLine::Perl, as well as a variety of others including: Term::ReadLine::Perl5, Term::ReadLine::Gnu, and Term::ReadLine::Tiny. These all failed, the most common problem being the process hanging when the Term::ReadKey dependency was being installed. Actually, installation of Term::ReadLine::Tiny worked fine but it didn't provide AddHistory.

    I spent some hours this morning looking into this and eventually came up with a solution. My basic Perl setup is: Win10 - Cygwin - Perlbrew - Perl 5.32.0. If you're experiencing the same problem, this solution may work for you: I can't make any guarantees as I don't have other systems on which to test this.

    The only thing that worked was a completely manual installation.

    Download then run the familiar incantation:

    $ tar zxvf TermReadKey-2.38.tar.gz $ cd TermReadKey-2.38 $ perl Makefile.PL $ make $ make test $ make install

    Download then a very similar incantation:

    $ tar zxvf Term-ReadLine-Gnu-1.37.tar.gz $ cd Term-ReadLine-Gnu-1.37 $ perl Makefile.PL $ make $ make test $ make install

    Now I get:

    $ cpan cpan shell -- CPAN exploration and modules installation (v2.28) Enter 'h' for help. cpan[1]>

    and moving through the command history and editing is now possible.

    If you were experiencing similar problems with a different setup to me — and found this worked as is, worked after some modification, or failed abysmally — please leave a note for the next reader.

    — Ken

Requesting review of new distribution information
4 direct replies — Read more / Contribute
by stevieb
on Jan 03, 2021 at 10:11

    Hey there fellow esteemed Monks!

    I've come to the Monastery today to ask a favour. I'm just finishing up a very long desired Perl distribution that I should be ready to publish within a day or two, and would like to ask if some of you would review and provide feedback on the README file to see if A) it's easy to understand, B) explains things unambiguously and thoroughly enough, and C) whether there are any features that I may have overlooked.

    The doc should provide enough of an understanding of what I'm trying to achieve, but here's a summary:

    I have over 50 CPAN distributions published, and many of them are tools to help the developer. I've always wanted a way to automatically manage my distributions from initial creation, inclusion of other features, and an automatic way to perform a release and the subsequent bump to a new development cycle. This distribution does all of this.

    The distribution is named Dist::Mgr, and although I've already released a version to the CPAN, it does not work, and was only put there to verify POD formatting etc. The included binary script is named distmgr, which is what the README focuses on.

    The link to the README on my repo is right here.

OT: memory to share available
7 direct replies — Read more / Contribute
by shmem
on Jan 01, 2021 at 17:09

    A few years after karlgoethebier it struck me. At age 59 $company laid me off. Good riddance.

    After 8 years of not being seen really, being handed around, trying in vain to get a peer programmer at the site, mobbing, bossing, you name it, it is good to depart. There's crucial code I wrote (a pile of, er...) living there which drives part of the business, and there has been no chance for handover. Go figure.

    I still feel responsible for all my perpetrations done, and they might come back to me for something something. Meanwhile I am enjoying the quietness of being unconcerned after having lived the quietness of disinterest paired with anxiety about when I will be fired.

    Eat it, sucker! you didn't live up to the task, I'm telling myself. As did the TCO, having the psychological sensibility of a tank (not talking about technical skills, at all). Yeah, true, I says, but there's two sides. Flowers don't blossom in the dark, and hurling somebody down the cellar stairs shouting "why are you running?" isn't fair either.

    Anyways, I might retire and try to implement perl in FORTH, or else. This is still humbly me at your service, at least at PerlMonks. I might have more time to read and post. The Great Constellation at the tip of Aquarius shows that "the times, they are a'changing".

    For the "or else" part, feel free to contact me.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Add your Meditation
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.