Skip to main content



Perl is growing and adapting to the modern times, just like a new shiny Plug-In Hybrid car. Plug-in hybrid cars have the best of both worlds, an electric motor that has an average range of 20-60 miles and after its range is depleted it goes on the good old reliable gas motor for a few hundred miles.

Perl has many new shiny tech ( think of this as the Electric motor side of the Plug-In Hybrid car ) like Dancer2, Mojolicious , Starman and now COR which is a new OO system that is part of the language ( and many other cool new cpan modules that I might have missed * feel free to share your favorite new cpan module in the comments)

Perl has done a good job at keeping backwards compatibility ( now think of this as the gas engine side of the plugin hybrid car ) where many companies can still reliably run its perl code ( even after upgrading perl and obviously a few tweaks in the codebase here and there )

The Perl community is still active and its cpan modules continue to be maintained. Yes we have experienced a shrinking in the Perl community but the community has maintained a focus on improving the core modules that are shipped in the language and has paid close attention to widely used cpan modules ( read up on cpan river model - https://neilb.org/2015/04/20/river-of-cpan.html )

If you used to write Perl code or your curious about it then this is the best time to give Perl 5.40 a try and play around with some of its new web frameworks, cpan libraries and its new OO system COR.

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




My job has led me down the rabbit hole of doing some scripting work in Perl, mainly utility tools. The challenge being that these tools need to parse several thousand source files, and doing so would take quite some time.

I initially dabbled in doing very light stuff with a perl -e one-liner from within a shell script, which meant I could use xargs. However, as my parsing needs evolved on the Perl side of things, I ended up switching to an actual Perl file, which hindered my ability to do parallel processing as our VMs did not have the Perl interpreter built with threads support. In addition, installation of any non-builtin modules such as CPAN was not possible on my target system, so I had limited possibilities, some of which I would assume to be safer and/or less quirky than this.

So then I came up with a rather ugly solution which involved invoking xargs via backticks, which then called a perl one-liner (again) for doing the more computation-heavy parts, xargs splitting the array to process into argument batches for each mini-program to process. It looked like this thus far:

my $out = `echo "$str_in" | xargs -P $num_threads -n $chunk_size perl -e ' my \@args = \@ARGV; foreach my \$arg (\@args) { for my \$idx (1 .. 100000) { my \$var = \$idx; } print "\$arg\n"; } '`; 

However, this had some drawbacks:
  • No editor syntax highlighting (in my case, VSCode), since the inline program is a string.
  • All variables within the inline program had to be escaped so as not to be interpolated themselves, which hindered readability quite a bit.
  • Every time you would want to use this technique in different parts of the code, you'd have to copy-paste the entire shell command together with the mini-program, even if that very logic was somewhere else in your code.

After some playing around, I've come to a nifty almost-metaprogramming solution, which isn't perfect still, but fits my needs decently well:

sub processing_fct { my u/args = u/ARGV; foreach my $arg (@args) { for my $idx (1 .. 100000) { my $var = $idx; } print "A very extraordinarily long string that contains $arg words and beyond\n"; } } sub parallel_invoke { use POSIX qw{ceil}; my $src_file = $0; my $fct_name = shift; my $input_arg_array = shift; my $n_threads = shift; my $str_in = join("\n", @{$input_arg_array}); my $chunk_size = ceil(@{$input_arg_array} / $n_threads); open(my $src_fh, "<", $src_file) or die("parallel_invoke(): Unable to open source file"); my $src_content = do { local $/; <$src_fh> }; my $fct_body = ($src_content =~ /sub\s+$fct_name\s*({((?:[^}{]*(?1)?)*+)})/m)[1] or die("Unable to find function $fct_name in source file"); return `echo '$str_in' | xargs -P $n_threads -n $chunk_size perl -e '$fct_body'`; } my $out = parallel_invoke("processing_fct", \@array, $num_threads); 

All parallel_invoke() does is open it's own source file, finds the subroutine declaration, and then passes the function body captured by the regex (which isn't too pretty, but it was necessary to reliably match a balanced construct of nested brackets) - to the xargs perl call.

My limited benchmarking has found this to be as fast if not faster than the perl-with-threads equivalent, in addition to circumventing the performance penalty for the thread safety.

I'd be curious to hear of your opinion of such method, or if you've solved a similar issue differently.

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



List of new CPAN distributions – Jun 2024 submitted by /u/perlancar
[link] [comments]


I need some help with the old Perl Gunnar Hjalmarsson's Ringlink program on my site. The forms work, the database gets added to and everything seems ready to go except for the email functions that depend on sendmail.

I have tried several things, installed the CPAN dependencies the program needs, tried Auron SendEmail and other programs and have thoroughly confused myself.

There's a test installation on my site, with the admin and password are both 'test'. There are copies of the CGI files and probably what needs looking at are rlmain.pm, rlconfig.pm and sender.pm

I am running Apache 2.4.54 on Windows 10 with Strawberry Perl installed. I am using the last published version Ringlink (v3.4)

I know this is an old program and the project probably not worth pursuing, but I really would like to give this a go to get it working and would be grateful for any suggestions.

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



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



The Once and Future Perl

Damian on top form as always. The modules this talk is based on are, of course, all both brilliant and incredibly useful. But the thing that's really impressed me here is the way he has taken some of his modules from a couple of decades ago and replaced them with calls to LLMs. That's food for thought.

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



Visual Exploration of Perl Camel at TPRC 24 ConferenceI was lucky enough to attend the perl and raku conference this year and had a great time meeting lots of awesome people.

I am primarily a designer by trade but do code as well. At the conference, I explored a number of original depictions of the perl camel for fun and this one was my favorite. The idea was to bring a strikingly modern feel to the Perl Camel. Loose inspiration for this symbol is code llama and p****n. This design exploration felt like my way to hack something during the conference!

The idea behind this simple symbol is that it could work nicely at very small sizes while still being visually clear. The font is a free open-source display font called Jaro. the first image was also a concept of placing "Perl" in the camel symbol to strengthen the association between the "perl" and the camel symbol as this may be helpful for new developers. I could spend much more time on this but thought I would share!

Love it? Hate it? Let me know what you think (especially if you like it)

https://preview.redd.it/ce8225s3dc9d1.png?width=5256&format=png&auto=webp&s=10a3c3ed4e0c9aea3f46d61308b75879be1d98e5

submitted by /u/North-Clue-2313
[link] [comments]







PSA: to get Net::SSLeay to build on a new M3 MBP I had to do export OPENSSL_PREFIX=/opt/homebrew/opt/openssl/include/openssl/ to get it to build on a new M3 MBP with an OpenSSL that was installed via brew install openssl

Filed an issue at https://github.com/radiator-software/p5-net-ssleay/issues/482

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



As the conference is happening in Las Vegas right now, recordings of the talks are being posted to YouTube.

https://www.youtube.com/@YAPCNA

Thanks to everyone planning, sponsoring, speaking and coding in the Perl space. I appreciate you all.

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



My site got exploited the other week. I had a backup of my WordPress domain, so after importing the backup, most of the infected files were gone. However, some files outside the public_html folder were infected. I deleted those files, and my website loads up fine. Just wondering, is there a way I can restore those files without having my hosting company reinstall Perl?

Thx in advance.

/home2/user1/perl5/lib/perl5/x/index.php: SL-PHP-FILEHACKER-fbo.UNOFFICIAL FOUND

/home2/user1/perl5/lib/x/index.php: SL-PHP-FILEHACKER-fbo.UNOFFICIAL FOUND

/home2/user1/perl5/bin/x/index.php: SL-PHP-FILEHACKER-fbo.UNOFFICIAL FOUND

/home2/user1/perl5/x/index.php: SL-PHP-FILEHACKER-fbo.UNOFFICIAL FOUND

-ABS

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



Sorry I didn't get this out here earlier (and it's an xpost from Perlmonks), but Perl Community (parent org of the Science Perl Committee that is initiated the Science Track) is giving out a "peoples choice" award at the end of Conference Lightning Talks. It's sincere gesture from us and allows anyone to vote for anyone in the Perl community at large, as a "thank you" from us.

link to Google voting form

The Science Track talks have been great, some are even starting to come online. Thanks to everyone who made this happen, especially the TPRC Planning Committee.

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




I’m a dev with 20yoe in mostly Java and js but have various amounts of experience with other languages. I’ve decided that I need Perl in my toolkit because I find it on even the most minimal boxes preinstalled and I can’t always install Java or Js just to do admin things. Typically I use bash for these tasks but I just need a little more ability to abstract than what bash easily provides. What would you all recommend as the place to start? Most guides that I run into assume that I’m a beginner to programming and it feels slow. My normal method of learning a new language is to stumble through building a web server but I’m not sure that the way to go here.

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



I am working with the IP::Geolocation::MMDB module which replaces the deprecated modules for GeoIP databases.

I am having trouble understanding how to extract data.

my $ip = "8.8.8.8"; my $db = IP::Geolocation::MMDB->new(file => "$geolitecitydb"); my $geodata = $db->record_for_address($ip); print Dumper($geodata); 

Using Data::Dumper as above to show the results, I see something like (truncated):
Dumper...........$VAR1 = { 'continent' => { 'geoname_id' => 6255149, 'names' => { 'de' => 'Nordamerika', 'es' => "Norteam\x{e9}rica", 'zh-CN' => "\x{5317}\x{7f8e}\x{6d32}", 'ru' => "\x{421}\x{435}\x{432}\x{435}\x{440}\x{43d}\x{430}\x{44f} \x{410}\x{43c}\x{435}\x{440}\x{438}\x{43a}\x{430}", 'fr' => "Am\x{e9}rique du Nord", 'ja' => "\x{5317}\x{30a2}\x{30e1}\x{30ea}\x{30ab}", 'en' => 'North America', 'pt-BR' => "Am\x{e9}rica do Norte" }, 'code' => 'NA' 

Supposing I just want to grab the value of continent=>names=>en portion (value: 'North America') and write it to a value -- how would I do this? I'm having problems understanding the documentation I'm reading to deal with hashes of hashes.

Most examples I can find online involve looping through all of this; but in my case, I just want to make $somevar = 'North America.' I'd like to repeat it for other data as well, which is returned in this hash.

It feels like something like:

$geodata{city=>names=>en} should work, but it doesn't.

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




I have been using version 5.22.1 for years, and it did what I needed to do. After all these years, I need some additional functionality, so I thought installing the latest might help.

Which is when I found that ActiveState has changed the installation process totally. Anyway, I went through the installation of the "recommended" version, and installation seemed to go fine.

I then ran the following simple code through both versions.

use HTTP::Tiny; my $url ='https://www.scrapingcourse.com/ecommerce/' ; my $response = HTTP::Tiny->new->get($url); print $response->{content}; 

Version 5.22.1 runs this fine and gives me the HTML of the page.
Version 5.36.3 gives me the following errors;

IO::Socket::SSL 1.42 must be installed for https support
Net::SSLeay 1.49 must be installed for https support

When I use the old ppm command for Version 5.22.1, it gives me a list of 271 packages installed.

When I used the new "state" command: "state packages", it showed nothing.

So I used "state" to "install" IO-Socket-SSL, and Net-SSLeay, and now those are the only two that show up in the "state packages" list.

But it did not change functionality. The error messages are still there, and no execution.

It doesn't complain about HTTP::Tiny.

I tried installing Strawberry. But it had a problem with a more complex part of my original project, so I went back to ActiveState 5.22.1, which works fine.

Anybody got any ideas about what I need to do to get 5.36.3 actually working?

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




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


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


Its been a long time since i've had to hack some code together so here just asking for advice as to where to start.

I have a group of printers (all have same web interface) on the corporate network. I would like to make a simple script that can login, and upload a config file (really its a list of users that have can scan documents, it doesn't matter what).

I've tried to google this with limited results, so wanted to reach out here to see if PERL would be the best answer for this.

I guess my question is, what modules should I look at to connect to a webpage in order to login then access a page behind the login and upload a file?

I looked into Mechanize but I do not believe it can handle javascript. Any advice or test scripts that do something similar would be greatly appreciated.

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




I’m currently having to modify a library that used Smart::Match extensively since I can no longer turn off the zillions of lines of experimental warnings in recent Perls. For people who are in a similar situation it’s looking like Data::Compare can replace the situations where I was doing ‘@foo ~~ @bar’, and it’s easy enough to write a “does this hash have this key” helper.

Meta complaint: I was already a bit annoyed at the whole smartmatch “oh whoops actually this is now experimental” saga but now that I’m stuck fixing this breakage I’m $annoyed++. Im getting annoyed enough that I may choose an older Perl that was “good enough” and just stop using the new ones

See also: https://www.reddit.com/r/perl/comments/pimwma/how_do_i_stop_smartmatch_is_experimental_at/

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



Hello all I have a .pl CGI program that calls a module with lots of code I'll call it LotsOfCode.pm now I need to update a few subs in it and possibly add a dependency.

The pl file looks like this:

main.pl

use LotsOfCode;

Lotsofcode->cat();

LotsOfCode->dog();

Lotsofcode->fish();

Now I'd like this to say the same but I need to improve fish and cat. Say LotsOfCode.pm looks like this:

package LotsOfCode

sub fish {}

sub dog {}

sub cat {}

1;

I'd like to

mkdir ./LotsOfiCode

nano LotsOfCode/fish.pm move sub fish{} here

nano LotsOfCode/dog.pm move sub dog {} here

nano LotsOfCode/cat.pm move sub cat {} here

what do I put in the top of these new files in \LotsOfiCode ?

package LotsOfCode::fish;

or

package fish; ?

or

nothing is what I have so far just

sub fish {}

then in LotsOfCode.pm

do I go:

package LotsOfCode

use LotsOfiCode::fish

use LotsOfiCode::dog

use LotsOfiCode::cat

1;

or

do LotsOfCode::fish;

do LotsOfCode::cat;

do LotsOfCode::dog;

Thank you all in advance I get the more than one way to do it idea of Perl but feel like I keep fumbling with mixing old and new code.

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



Why is "!!" considered bad form in Perl? [updated for 2024] submitted by /u/EvanCarroll
[link] [comments]


Filed under "Things that one can do, but why?" , here is the repo of using Perl to learn assembly, or rather use Perl to avoid

  1. having a C driver program
  2. make files
  3. multiple files (Inline::ASM allows one to keep Perl and Assembly in the same file

Bonus :

  1. it is insane how efficient some of the list utilities at List::Util are !
  2. Seems Github uses file extensions to count lines of code in a language (the repo is considered all Perl

Link https://github.com/chrisarg/perlAssembly

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



Anybody wants to add a Perl implementation to this?

(I'm currently on a train and have to change soon, but if nobody implements I might give it a try later)

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




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



Enhancing non-Perl bioinformatic applications with #Perl: Building novel, component based applications using Object Orientation, PDL, Alien, FFI, Inline and OpenMP - Archive ouverte HAL https://hal.science/hal-04606172v1

Preprint for the #TPRC2024 talk to be delivered in 10days

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



This might be Perl/docker-perl#161 but if I filed this in the wrong place, let me know. Keeping these things current is the sort of thing I'd pay for.

Pulling perl images locally give the same warnings for old perl versions, although my local docker will still run them:

$ docker pull perl:5.14 5.14: Pulling from library/perl Image docker.io/library/perl:5.14 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 

Here's what I'm getting today from GitHub Actions. Sure, I see all sort of warnings to upgrade node, but nothing about this change:
/usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Warning: Docker pull failed with exit code 1, back off 5.148 seconds before retry. /usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Warning: Docker pull failed with exit code 1, back off 4.06 seconds before retry. /usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Error: Docker pull failed with exit code 1 

From this snippet in my GitHub workflows (e.g. .github/workflows/linux.yml)
 matrix: os: - ubuntu-22.04 perl-version: - '5.8' - '5.10' - '5.12' - '5.14' - '5.16' - '5.18' - '5.20' - '5.22' - '5.24' - '5.26' - '5.28' - '5.30' - '5.32' - '5.34' - '5.36' - 'latest' container: image: perl:${{ matrix.perl-version }} 

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



I have an input string that has "comments" in it that are in the form of: everything after a ; is considered a comment. I want to remove all comments from the string and get the raw text out. This is a pretty simple regexp replace except for the fact that ; characters are valid non-comments inside of double quoted strings.

How can I improve the remove_comments() function to handle quoted strings with semi-colons in them correctly?

```perl use v5.36;

my $str = 'Raw data ; This is a full-line comment More data ; comment after it Some data "and a quoted string; this is NOT a comment"';

my $clean = remove_comments($str);

print "Before:\n$str\n\nAfter:\n$clean\n";

sub remove_comments { my $in = shift();

$in =~ s/;.*//g; # Remove everything after the ; to EOL return $in; 

} ```

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



Hi,

im looking to put my website written in perl that currently runs locally inside apache out on the internet.

I dont want to host myself, and i dont have lots of spare time to config or money to spend for a vps.

Does anyone have experiences and can recommend a webhoster for maybe 10-15 bucks a month where i can just get a simple interface with ssh, where i can put an index.cgi somewhere(dont care if its in cgi-bin or public_html or something else,

i want something where i can just checkout my git repo thta contains index.cgi in its root and just works.

Thank you in advance!

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



Thanks to a pile of new data added and old data cleaned up (most of that work done by Philippe Bruhat and Aristotle Pagaltzis) and some help from Copilot on the Javascript, there's a lot of new, interesting information on my Perl Steering Council web page - https://psc.perlhacks.com/

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






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


I know it is something of an obscure corner of everything that Perl can do, but Perl is excellent for "one-liners".

Has anyone developed a module of convenience functions for use with one-liners? I have something in progress but I'd like to see if there is established prior art.

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



Stack:

Nginx FCGI CGI::Fast HTML::Template::Compiled Redis CentOS Linux 7.9 spawn-fcgi 

I have a Perl application that runs on the above stack.

On process init it does a lot of loading of big hashes and other data into global variables that are mostly preloaded and cached in a distributed Redis install.

To start the application spawn-fcgi creates 6-8 processes on a port nginx then connects to trhough their fcgi module.

The challenge:

— The init process is computing and time consuming; and doing that concurrently six times peaks CPU and overall leads to a ~20-25 second delay before the next web request can be served. And the initial request to each of the six processes has that delay.

I tried loading the content in question directly from Redis on demand but the performance keeping it in memory is naturally much better (minus the initial delay).

is there an architectural pattern that I am not considering here? I am thinking of things as eg. only spinning up one process, having it initialize and then clone(?) it a few times for serving more requests.

I could also think of a way where only 1 process is spawned at a time and once it completes initiation the next one starts; would need to verify that spawn-fcgi can support this.

So my question to this community is if I am missing an obvious better solution than what is in place right now / what I am considering.

Thanks in advance.

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



I am moving a pile of stuff off of an older Intel Mac Mini onto an M2. Have almost everything migrated, but am stuck on getting a Perl script that relies heavily on DBD::mysql to work. I finally got cpan to build the module, but when I try to use it in actual code, I get: dyld[82852]: missing symbol called. I go through this mess periodically with OS upgrades...and it's possible that this is (once again) OSX ignoring the module because it's not signed. But the given error sounds more like Perl not finding the dynamic library(s) the module was built with...if I just have a script containing "use DBD::mysql;", that doesn't throw an error, which suggests Perl found the module and loaded it. But chokes when it tries to use it.

I'd be fine with building this module with static libraries, if the process of doing so is easy. But have not seen an easy option to cpan to go that route. Suggestions?

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




If the length of some_array is 101 then the code below gives an illegal divide by zero error, but when the length of the array is 102 it's fine. I noticed that 101 results in a float and 102 results in a whole number. Maybe that has something to do with or maybe it's because the length of the array is unknown ahead of time. I'm not sure.
my $result = $some_value / scalar(split(",", $some_array[0])); 

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