Skip to main content


Hello, I currently have Perl 5.32 and I'm building Perl 5.40.0 right now. If I install the 5.40.0 build to my system, would it mess my entire system ? Thanks. I'm using dragora GNU / Linux.

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




I'm a big fan of the PCG32 PRNG. It's simple, fast, and well documented. As is usually the case when I find interesting code I try and find a way to implement it in Perl. PCG32 poses an interesting problem when one tries to implement it in Perl because all the math is performed using unsigned integers and overflow. Most PRNGs use large numbers and overflow to work, that's their secret sauce.

Perl does not have a native unsigned type so I had to learn the guts of how Perl does math so I could emulate it. I ended up coming up with two different implementations, a native Perl implementation, and a version that uses Math::Int64. Surprisingly the native version was significantly faster.

Both implementations with detailed comments are available here if you're interested in learning more about how to do integer style math in Perl.

I learned a lot, and it was a fun exercise. Thanks to reddit.com/u/DrHydeous for helping me with the integer rollover.

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







This is a two part story:

  1. Part 1 goes over the subtleties of monitoring DRAM use by R applications (which seems impossible or very difficult to do from within R, except in a valgrind kind of way)
  2. Part 2 shows the Perl solution and how one can make it play nice from within R

Code is released under the MIT license - feel free to adapt to your use cases (and perhaps someone can provide a Windows version!)

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





I like learning and working in Perl. I personally find it more enjoyable to program in than Python. Python isn't difficult, I just never took a liking to it with its lack of braces and strict indentation. The lack of braces can at times make it difficult to find out what's enclosed in what as code gets longer. Braces just make sense to me.

A lot of syntatical constructs remind me of C which may be the reason why I like it so much. I just wish I can enjoy it without feeling bad or ostracized for liking a less popular language that people claim is only used in legacy systems or on the verge of dying.

Anyone else feel this way ? 🙁

submitted by /u/Warm-Scholar6106
[link] [comments]



In 1999, Perl was the first programming language I truly explored. The beautiful language confirmed my passion for web development. By utilizing CGI and mod_perl, I contributed to building scalable websites during that time. I loved it.

However, my frustration grew with the community the more I used it. While other languages were trying hard to ease their ecosystems, and shine them up, I felt the Perl community were happy with where they were, and saw no need for change. Status quo, and that was that.

I was using Perl Catalyst at a job back in 2011. I went to visit a friend in a startup incubator and I saw him execute a "git push" from the command line. It pushed his whole Ruby on Rails app directory to a Hook environment. I was blown away. It changed my life; I quit Perl that day, and moved over to Ruby. I had read nasty comments on RoR from the Perl community, but really they missed the point: it let developers just focus on development. Perl Catalyst was powerful, but the documentation was very weak, and just to get it installed on a machine took so much manual intervention, and time. I once asked questions about best design practices for custom libs, and was met with scorn on an irc channel.

I type this with nostalgia, as I love Perl so much, however, I wish the community just helped with the toolings, and kept up to date with the demands.

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




I've been playing with the idea of using a Gtk3::TreeView to create a collapsible menu. I've managed to create the GUI OK, but I've struck a roadblock... Search as I may, I can't find out how to fix it up so that when I click on a bottom-level entry, an action is performed.

I'm coming to the conclusion that it seems not to be possible, but in case it is, can anyone point me at an example as to how to do it? It may be that the example I've cannibalised isn't doing in the right way for this, of course...

Thanks.

[Edit]: to answer my own question, in case anyone comes here looking for the same information, I found a useful example here. The notes are in German, but it's easy enough to work out what's going on in order to get a working menu.

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







Has anyone else been contacted directly and encouraged to make a donation to help fund a new Perl jobs & staffing service? The approach might be legit but I just want to make sure that I'm not being scammed and that the person who approached me is in control of the vendor account to which funds are being vectored. Hence, the post here.

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



Today, first-time perl.com contributor u/jacktokyo tells us about a new Perl module: DateTime::Format::RelativeTime. This library is designed to mirror its equivalent Web API: Intl.RelativeTimeFormat. 💪

perl.com/article/release-of-ne…

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










I was using my $tmp = glob("file20240101.*") to find the full filename regardless of the extension(I knew there was only one of each file), when I found glob was alternating between working and failing

Rendering it as my ($tmp) = glob("file20240101.*") fixed the problem, but I'm wondering why, If it was going to go wrong I'd have thought treating glob's list in a scalar context would return the number of elements in the list

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

for (1..4) {
my $tmp = glob($0);
print "$_ $tmp\n";
}
print "###\n";
for (1..4) {
my ($tmp) = glob($0);
print "$_ $tmp\n";
}

Output:
1 glob.pl
Use of uninitialized value $tmp in concatenation (.) or string at glob.pl line 7.
2
3 glob.pl
Use of uninitialized value $tmp in concatenation (.) or string at glob.pl line 7.
4
###
1 glob.pl
2 glob.pl
3 glob.pl
4 glob.pl

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




Hi,

I don't get why this produces a syntax error:

my %r = map { "a$_" => 1 } qw(q w);

yet this works:

my %r = map { "a" . $_ => 1 } qw(q w);

What is going on here?

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




Let me explain my goal.

Let's say I have a file with a set of paths to files:

/usr/lib32/libssl.so

/usr/lib32/libz.so

...

and so on.

What's an easy way in perl to turn that input into:

/usr/lib32/libssl.so /usr/lib32/libssl.so

/usr/lib32/libz.so /usr/lib32/libz.so

...

Basically duplicate every string to the same line, delimited by a space?

Thanks for any assistance. I use perl's regex regularly for substitutions and the like (instead of using sed) and I prefer PCRE to sed. That said, not familiar with a way to do this.

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





I have the pleasure to announce the release of the new Perl module DateTime::Format::RelativeTime, which is designed to mirror its equivalent Web API Intl.RelativeTimeFormat

It requires only Perl v5.10.1 to run, and uses an exception class to return error or to die (if the option fatal is provided and set to a true value).

You can use it the same way as the Web API:

```perl use DateTime::Format::RelativeTime; my $fmt = DateTime::Format::RelativeTime->new( # You can use en-GB (Unicode / web-style) or en_GB (system-style), it does not matter. 'en_GB', { localeMatcher => 'best fit', # see getNumberingSystems() in Locale::Intl for the supported number systems numberingSystem => 'latn', # Possible values are: long, short or narrow style => 'short', # Possible values are: always or auto numeric => 'always', }, ) || die( DateTime::Format::RelativeTime->error );

# Format relative time using negative value (-1). $fmt->format( -1, 'day' ); # "1 day ago" # Format relative time using positive value (1). $fmt->format( 1, 'day' ); # "in 1 day" 

```

This will work with 222 possible locales as supported by the Unicode CLDR (Common Locale Data Repository). The CLDR data (currently the Unicode version 46.1) is made accessible via another module I created a few months ago: Locale::Unicode::Data

However, beyond the standard options, and parameters you can pass to the methods format and formatToParts (or format_to_parts if you prefer), you can also provide 1 or 2 DateTime objects, and DateTime::Format::RelativeTime will figure out for you the greatest difference between the 2 objects.

If you provide only 1 DateTime object, DateTime::Format::RelativeTime will instantiate a second one with DateTime->now and using the first DateTime object time_zone value.

For example:

perl my $dt = DateTime->new( year => 2024, month => 8, day => 15, ); $fmt->format( $dt ); # Assuming today is 2024-12-31, this would return: "1 qtr. ago"

or, with 2 DateTime objects:

```perl my $dt = DateTime->new( year => 2024, month => 8, day => 15, ); my $dt2 = DateTime->new( year => 2022, month => 2, day => 22, ); $fmt->format( $dt => $dt2 ); # "2 yr. ago"

```

When using the method formatToParts (or format_to_parts) you will receive an array reference of hash reference making it easy to customise and handle as you wish. For example:

perl use DateTime::Format::RelativeTime; use Data::Pretty qw( dump ); my $fmt = new DateTime::Format::RelativeTime( 'en', { numeric => 'auto' }); my $parts = $fmt->formatToParts( 10, 'seconds' ); say dump( $parts );

would yield:

perl [ { type => "literal", value => "in " }, { type => "integer", unit => "second", value => 10 }, { type => "literal", value => " seconds" }, ]

You can use negative number to indicate the past, and you can also use decimals, such as:

my $parts = $fmt->formatToParts( -12.5, 'hours' ); say dump( $parts );

would yield:

perl [ { type => "integer", unit => "hour", value => 12 }, { type => "decimal", unit => "hour", value => "." }, { type => "fraction", unit => "hour", value => 5 }, { type => "literal", value => " hours ago" }, ]

The possible units are: year, quarter, month, week, day, hour, minute, and second, and those can be provided in singular or plural form.

Of course, you can choose a different numbering system than the default latn, i.e. numbers from 0 to 9, as long as the numbering system you want to use is of numeric type. There are 77 of those our of 96 in the CLDR data. See the method number_system in Locale::Unicode::Data for more information.

So, for example:

perl use DateTime::Format::RelativeTime; use Data::Pretty qw( dump ); my $fmt = new DateTime::Format::RelativeTime( 'ar', { numeric => 'auto' }); my $parts = $fmt->formatToParts( -3, 'minutes' ); say dump( $parts );

would yield:

perl [ { type => "literal", value => "قبل " }, { type => "integer", value => '٣', unit => "minute" }, { type => "literal", value => " دقائق" }, ]

or, here we are explicitly setting the numbering system to deva, which is not a system default:

perl use DateTime::Format::RelativeTime; use Data::Pretty qw( dump ); my $fmt = new DateTime::Format::RelativeTime( 'hi-IN', { numeric => 'auto', numberingSystem => 'deva' }); my $parts = $fmt->formatToParts( -3.5, 'minutes' ); say dump( $parts );

would yield:

perl [ { type => "integer", value => '३', unit => "minute" }, { type => "decimal", value => ".", unit => "minute" }, { type => "fraction", value => '५', unit => "minute" }, { type => "literal", value => " मिनट पहले" }, ]

The option numeric can be set to auto or always. If it is on auto, the API will check if it can find a time relative term, such as today or yesterday instead of returning in 0 day or 1 day ago. If it is set to always, then the API will always return a format involving a number like the ones I just mentioned.

I hope you will enjoy this module, and that it will be useful to you. I have spent quite a bit of time putting it together, and it has been rigorously tested. If you see any bugs, or opportunities for improvement, kindly submit an issue on Gitlab

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







perl.com is always looking for quality content. It's quite easy to get started. You can even re-purpose an existing article if you think it fits the format. Thanks to David Farrell for making it easy with this getting started tutorial.

perl.com/article/how-to-write-…

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










I've created a Christmas coupon for a free copy of Leaning Perl Exercises. This runs from all day on December 25 from midnight to midnight UTC for the first 37 uses (happy birthday Perl!).

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



I'm a sysadmin who has very little experience with perl (who am I kidding, none). I recently came across some legacy code that "broke" due to migrating systems which leads me to some questions. Specifically the problem had to do with UTF8 support. Our environment requires supporting french characters.

what are the pros and cons of using these two?:
# open(MAIL, "| /usr/sbin/sendmail -t -oi")
# use Net::SMTP;

postfix is installed on all systems in question. If it matters the old systems are rhel7 based and the new systems are rhel9 based.

In my attempts to troubleshot the code vs system issues - using NET::SMTP worked very well for me. But the Devs not wanting to update their code insist I find a solution for their old sendmail version. That was done by setting postfix to "smtputf8_enable = no".

So what are the pros and cons of each method?
What are use cases for one over the other?
Are there other better modern ways of sending email either with perl directly or by using the systems smtp app?

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



I have no idea to what extent this is official, but GitHub is not updating any Perl package in the GitHub action runners. This is the current response to a request to post back LWP::protocol::https which was there before, but vanished, needing an installation that takes a good amount of time.

submitted by /u/Sea-Bug2134
[link] [comments]