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
Shout out to Monks young and old
1 direct reply — Read more / Contribute
by stevieb
on Dec 26, 2023 at 01:10

    Been a while since I first came here... ~2001 or something as a lurker, and joined in ~2009 or so.

    It's been a journey. It's late in what me and my family would call Christmas Day, but not too late to say Merry Christmas.

    As I'm sure that isn't specific to me, there's been both personal loss, and loss to us within the community over the past year. I am writing this post not to contemplate loss, but to commemorate what we have gained. It is remarkable to me not just the quantity, but the actual quality of posts we've seen from newer members this past year. Not only that, but I see an upswing of newer members who are actually paying attention to subtleties of the old-timers. Learning old school Internet etiquette and actually using it. Not just here, but in the larger world.

    This Christmas, I want to thank everyone here, former, current and future, for not only creating, carrying and moving forward Perl's legacy, but the legacy that we as Perl Monks care deeply about. Respect, Honour, Integrity. Caring about one another. Pass it forward. Do for the next person that someone has done for you.

    I won't name names, but all y'all whom I'm speaking of will get a shiver when you read this, so take a bow.

    Merry Christmas, and Happy New Year

    -stevieb

    20231225 2210 hrs PST

Fast sliding submatrix sums with PDL (inspired by PWC 248 task 2)
5 direct replies — Read more / Contribute
by Anonymous Monk
on Dec 25, 2023 at 19:51
    Task 2: Submatrix Sum Submitted by: Jorg Sommrey You are given a NxM matrix A of integers. Write a script to construct a (N-1)x(M-1) matrix B having elements that are the sum over the 2x2 submatrices of A, b[i,k] = a[i,k] + a[i,k+1] + a[i+1,k] + a[i+1,k+1] Example 1 Input: $a = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ] Output: $b = [ [14, 18, 22], [30, 34, 38] ]

    I tried to crank it up for entertainment -- to solve not "2x2", but arbitrary "WxH" sub-matrices of (relatively) large matrices. Sadly, it was too late into many stupid plots and tables, when I realized, that excessive summation isn't required at all. Sliding (moving) sum (or average, min/max, etc.) is a well known concept -- duh! not to un-educated me, alas. And so maybe "2x2", not "WxH", in the task, was selected not only because PWC tries to accommodate new learners. Anyway, I implemented "sliding submatrix sums" algorithm only at a later stage, in PDL, and didn't "backport" it to pure Perl (nor Pdlpp) because had already been somewhat fed-up with this 248-2, but decided to present sanitized results as a meditation.

Merry Xmas! =)
2 direct replies — Read more / Contribute
by LanX
on Dec 24, 2023 at 10:43
    Merry Christmas ;)

    May the peaceful comfort of your family distract you for a while from this war ridden world!

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

    PS: Btw 12000 posts?!? Time to retire! ;)

What is the right amount of onboarding?
3 direct replies — Read more / Contribute
by talexb
on Dec 19, 2023 at 23:30

    In my last post (Re^2: Are blessings a new thing?), I talked about Asking Too Many Questions, something I've done at various jobs I've had. Specifically, when I land at a new job, I like to get a little better grounding on What The Business Does To Earn Money (good to know), as well as something about the technical stack, and how the software's organized. I don't apologize for that -- that's how I like to work.

    When I started at a desktop publishing software company (in 1987), the CTO was able to draw me a diagram with the various modules on it, showing how the data flowed between them -- and that all made sense. The fact that these modules were actually individual .com files compiled by Turbo Pascal and jury-rigged to run together as a single GEM application was a little scary, but it worked.

    I've also worked at a place where the software running things was over a hundred Catalyst modules, and I was left to my own devices to Figure it All Out; there was no overview, no roadmap. To my mind, this is the wrong approach. If you have a code-base of thousands of files and no documentation, are you surprised there are questions?

    When a new developer is hired, you want to give them the best possible opportunity to become productive as soon as possible. It also helps if the team that they're going to a) has helpful people who b) have the time and c) the ability to do this orientation. That probably involves finding a couple of basic parts of the system, and walking through how things look in the database, in the code, and from a Support point of view. (Here's how we store information about widgets, here's the code where we figure out what kind of widget's required, and here's how customer service can look up a customer's widget order.)

    After asking all of those questions, I do give back, though -- when I had Co-op students at a recent job, I was happy to explain how things worked in the company's software, and talked about the business model, the database layout, how the release management worked, what support did, how we dealt with the flow of information from our partners, and even got a chance to talk about software craftsmanship, from the point of view of a veteran (ugh, I guess that's me).

    The right amount of onboarding is when the new developer can look at a ticket, understand what needs to be done, know where to go in order to start developing and testing a solution, and finally present a useful PR to the team. So onboarding is education -- and everyone knows that in software development, education is continuous.

    And Asking Questions should be OK!

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

22 years, and about a quarter century of Perl
4 direct replies — Read more / Contribute
by talexb
on Dec 12, 2023 at 12:06

    It's that day again, my Monk Day. I'm up to 22 years on this site, and as the title says, probably 25 years noodling around with Perl. What a long, strange trip it's been.

    I still host the monthly Perl Mongers monthly meeting in Toronto, and our discussion in November edged over to which editor people used. Like anything else, you use whatever tool works best for you. I'm very impressed by people who use emacs -- it seems insanely complicated. Using tmux with one panel as an editor and another as a bash prompt, is about as complicated as I get.

    Perl's the same situation -- if it's a tool you like and can get things done with, great. If there's a new shiny thing you prefer, great. I'm too old to be swayed by people saying, "Oh, no one uses Perl anymore." I use it, thus negating their generalization.

    Dare I say .. here's to another 22 years? :)

    Edit: OK, I got my quip this time:

    Happy Monkday!!1! You've been here 22 invigorating years. Did you make a wish?
    Nope, no wish. Just a reminder that I hear in my head, now and again: "Your fear is boring." Just keep moving.

    Also, Happy Winter Solstice, for all those that observe.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

App-lcpan: Amazing Dependency Graph
3 direct replies — Read more / Contribute
by kcott
on Dec 06, 2023 at 18:39

    I was asked to evaluate the lcpan script from the App-lcpan distribution for $work.

    I thought I'd just share its amazing dependency graph. ☺️

    — Ken

Google inactive account policy
No replies — Read more | Post response
by Cow1337killr
on Nov 28, 2023 at 17:33

    I don't know if any of my PerlMonks associates have source code or whatever on Google Drive or important email conversations with fellow programmers on GMail, but there is a distinct possibility that some of you have been heads-down coding and are not aware of...

    https://www.forbes.com/sites/daveywinder/2023/11/28/gmail-and-photos-content-purge-starts-in-5-days-protect-your-data-now/?sh=2dae705950e7

    It is not just your GMail account or pictures of you hanging out with Larry...

    https://support.google.com/accounts/answer/12418290#zippy=%2Cif-you-want-to-recover-your-account%2Chow-to-check-your-activity-status

    Time is not on your side. ("December 1, 2023 is the earliest a Google Account will be deleted due to this policy.")

    And now my editorial:

    Here we are on the cusp of A.I. and the world's biggest A.I. / Search engine / Fill in the blanks company has nothing better to do than send us this Christmas present (i.e., a lump of coal)?

PWC 244 task 2 in linear time
3 direct replies — Read more / Contribute
by Anonymous Monk
on Nov 27, 2023 at 13:22

    Disclaimer: it's clickbait. The plot is curved, solution isn't linear, despite lack of nested loops, -- but fast.

    Task 2: Group Hero
    Submitted by: Mohammad S Anwar
    
    You are given an array of integers representing the strength.
    
    Write a script to return the sum of the powers of all possible 
    combinations; power is defined as the square of the largest number 
    in a sequence, multiplied by the smallest.
    
    Example 1
    
    Input: @nums = (2, 1, 4)
    Output: 141
    
    Group 1: (2) => square(max(2)) * min(2) => 4 * 2 => 8
    Group 2: (1) => square(max(1)) * min(1) => 1 * 1 => 1
    Group 3: (4) => square(max(4)) * min(4) => 16 * 4 => 64
    Group 4: (2,1) => square(max(2,1)) * min(2,1) => 4 * 1 => 4
    Group 5: (2,4) => square(max(2,4)) * min(2,4) => 16 * 2 => 32
    Group 6: (1,4) => square(max(1,4)) * min(1,4) => 16 * 1 => 16
    Group 7: (2,1,4) => square(max(2,1,4)) * min(2,1,4) => 16 * 1 => 16
    
    Sum: 8 + 1 + 64 + 4 + 32 + 16 + 16 => 141
    
Emojis for Perl Monk names
12 direct replies — Read more / Contribute
by eyepopslikeamosquito
on Nov 17, 2023 at 03:02
Perl Secret Operator Emojis
6 direct replies — Read more / Contribute
by eyepopslikeamosquito
on Nov 05, 2023 at 01:40

    To continue my learning of Unicode Emojis, I thought it'd be fun to try to concoct emojis for some of Perl's famous secret operators.

    Here's what I've come up with so far:

    NameOperatorEmojiNotes
    Diamond<>💎nicknamed by Geneva Wall circa 1994
    Spaceship<=>🚀nicknamed by Heidi Wall and Randal L. Schwartz (merlyn 🪄) circa 1994
    Saturn*=( )=🪐scalar/list context
    Kite~~<>🪁a single line of input
    Babycart@{[ ]}👒🛷list interpolation, invented by Larry 🧱 (TimToady) circa 1994

    *Note: I have chosen not to use the taboo name for this secret operator used at perlsecret

    I found this exercise to be surprisingly challenging. Unable to find an emoji for BooK's quirky Babycart (or a pram), I opted instead to look for emojis that do justice to the LanX's imaginative suggestion of Mexican Sledge -- because he visualizes @{[ ]} as a guy with sombrero dragging a sled(ge) uphill.

    Please feel free to suggest alternative Unicode emojis for the secret operators above and to concoct emojis for other secret operators.

    See Also

    Updated: removed duplicate Mexican Sledge reference; added attribution to Heidi Wall; added Wall emoji for Larry and magic wand emoji for merlyn.

    👁️🍾👍🦟
2024 Perl Conference - Science Track Interest Survey
4 direct replies — Read more / Contribute
by oodler
on Nov 01, 2023 at 00:22
NHL Hockey Fans?
2 direct replies — Read more / Contribute
by stevieb
on Oct 24, 2023 at 02:39

    I'm Canadian, and hockey is in my blood. I've been on skates since I was before I remember.

    Being from Toronto, I have my team.

    For the last couple of years, I used an app on my phone that would alert me 15 minutes before my teams played (Toronto and Edmonton) so that I had an opportunity to set up recording on my PVR.

    In the last two days, I had to refuse the changes in said app's T&S because they wanted info beyond what was needed, so I decided immediately to delete the app. I then of course had to figure out a way to write my own alert software.

    I have. As I've done for a long time, I take a problem, and create a Perl solution to produce data from a source that is external. This is no different.

    I already have prototype working software. My question is this:

    If you're a hockey fan, is there anything specifically you'd want to look up? I already have it pegged as NHL::API, so your feedback will dictate the interface.

    Thanks :)

    -stevieb

RFC: Export tags for builtin pragma
3 direct replies — Read more / Contribute
by kcott
on Oct 19, 2023 at 13:42

    G'day All,

    I'm intending to propose export tags for the builtin pragma. I'd appreciate any comments you may have about this. Thankyou.

    A Brief History of the 'builtin' Pragma

    My Usage of the 'builtin' Pragma

    When released, I often play around with experimental features; however, I never use them in production-grade code. I did the same with the builtin pragma and found many to be useful: in some cases, I also found the import lists to be quite unwieldy.

    When Perl v5.40.0 is released, presumably sometime next year, I will probably start using many of the stable functions provided by the builtin pragma in production-grade code. I would like easier to use import lists; accordingly, I'm proposing a number of export tags.

    Proposed Export Tags for the 'builtin' Pragma

    :bool
    Exports: true, false, is_bool.
    :weak
    Exports: weaken, unweaken, is_weak.
    :ref
    Exports: blessed, refaddr, reftype.
    :round
    Exports: ceil, floor.
    :stable
    Exports all stable (i.e. non-experimental) functions.
    :all
    Exports all functions.

    — Ken

A Perl 3 bug in the debugger
2 direct replies — Read more / Contribute
by pemungkah
on Sep 20, 2023 at 17:25
    I recently posted about this on my blog, but it's worth a quick post here too.

    There's a fun little bug in the debugger, which you can see like this. Create a dumb little script. Anything will do.

    #!/bin/perl use strict; use warnings; print "we"; print "just"; print "need"; print "something"; print "to"; print "list";

    Now let's start up the debugger.

    perl -d zz.pl Loading DB routines from perl5db.pl version 1.77 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(zz.pl:5): say "we"; DB<1>

    All as expected, but now:

    DB<1> l 1.2 1.2 use strict; DB<2> l 2.2 use warnings; 3.2 use feature 'say'; 4.2 5.2: say "we"; 6.2: say "just"; 7.2: say "need"; 8.2: say "something"; 9.2: say "to";

    That's kind of unexpected, but it gets better!

    DB<2> l 1.1.3.5 1.1.3.5 use strict; DB<3> l 2.1 use warnings; 3.1 use feature 'say'; 4.1 5.1: say "we"; 6.1: say "just"; 7.1: say "need"; 8.1: say "something"; 9.1: say "to";

    Why does this happen? well it goes back to commit a687059cbaf, which is the one that moves the debugger into lib in Perl 3. The pattern used to capture the line number specification is (\d\$\.)+, which matches all kinds of things, including floating-point numbers, IPv4 addresses, and other junk. The overall pattern used to parse the l command arguments changes over time, but that basic match to extract a "line number" never does.

    You may be thinking, "yeah, okay, I see that, but why does the debugger show the floating-point line number?" The reason is that the line number spec is captured as a string. THe debugger stores the source code of the current file in an array whose name is not a valid Perl variable name, and uses the line number spec captured by the l command to index it.

    When Perl indexes an array, the index value is converted to an integer if possible, because array indexes have to be integers. The line spec we have is captured and stored as a string, so when we try to index the source array with it, "1.22" becomes the integer 1, and we find line 1. The command uses the value of the index variable (remember, that's still a string!) to print the line number, and so we end up with a floating-point line number.

    Now, when we run the bare l command, the string "1.22" is still in the list command's "last line listed" variable, and Perl simply takes that variable and adds 1 to its contents to look for the next line. Since the contents are a string that looks like a floating point number, Perl converts it to a float, adds 1.0 (so we don't downgrade it from a float), and assigns that back to the current line number,so we get lines 2.22, 3.22, and so on.

    I've submitted a patch to fix this for 5.40, but it's pretty surprising that we've had this bug for 32 years!

A small step...and a giant leap for Bod
2 direct replies — Read more / Contribute
by Bod
on Sep 07, 2023 at 06:05

    My 1000th post!

    It's a little under 3 years since I created an account here on Perl Monks. For many years, I'd occasionally visited The Monastery thanks to Google leading me here when I asked a Perl-related question - which was quite frequently. But, back in November 2020, I had a few new projects going on and thought I needed to "raise my game". I had no concept of what that actually meant.

    My expectation was that I'd learn a few new coding styles, be a bit quicker and, perhaps, a bit clearer.

    What has actually happened, and continues to happen, is that my whole approach to writing code has changed...drastically!

    Allow me to illustrate by way of an example...

    Just this week I was writing some code for the admin part of my partner's website Pawsies. We need to be able to upload pictures of dogs that we look after, and it's helpful if those pictures are square so they display consistently.

    The whole website uses Template - something I discovered in The Monastery. The web scripts are in their own directory and not mixed up with the other site files, again a learning from The Monastery. The upshot is sites that are easier to navigate, easier to link to as everything is not in the cgi-bin and easier to maintain.

    However, it goes much further than that.

    In the past, if I wanted square images, I would have hard-coded the logic to produce them into the script that needed them. But this week, instead I wrote a module to do only that operation. It is where my thought process started, it was not an afterthought. The design started with deciding exactly what it was supposed to do and by jotting down how I would know if it was successful. The basis of a test!

    I then looked to see if there were any extra generalisations that could be made to make it more useful to other people or when I reuse it elsewhere. So, a resizing parameter was added to change the size of the square image and a position parameter was added to determine where abouts the square is taken from in the original image.

    Only then was the code written followed by the tests...

    Once the tests all ran fine, it was bundled up and uploaded to CPAN for all to use. Currently as a dev release so I get some test results before the production release. It's all looking good...

    Before joining The Monastery this would have been a bit of messy, but functional code locked away somewhere in a difficult-to-maintain script. I considered CPAN modules to be for other, superior "proper" coders...not for me. Now I look for the best way to do it for my needs now, my needs in future when I come to maintain the code or need similar functionality and for the needs of the wider Perl community as The Monastery has shown me that I have something to contribute as well as to learn.

    Watch out for a testing question coming soon - one of the tests for Image::Square required visually inspecting the output image and I don't know how to convert that into a usable test...see, lots more to learn and that's something I fully embrace!

    Thank you to everyone who has helped, inspired, questioned and critised me over the last 1000 post - it really is appreciated 👍


Add your Meditation
Title:
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, details, 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, summary, 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.