Skip to main content




I would be interested to know why you chose Perl and how long you have been using it and what for.

I have just returned to Perl after many years away, think decades rather than a couple of years. Consider me a noob as I've long forgotten anything I knew about the language.

I run a small home webserver, Apache on Windows 10 with Strawberry Perl, and recently started some projects starting with moving away with things like Google Analytics and going back to some old log analyzers such as AWStats, which is still being maintained, and W3Perl, which is not. Even more recently I have started using Ringlink.

Perl is still being developed, Strawberry, Active State, CPAN etc. but lost out to PHP and Python. Just like COBOL, I can easily imagine thousands of systems depend on Perl.

submitted by /u/brisray
[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]


ar_foo and $bar come from a text file.
This throws an illegal divide by zero error:
my @ar_foo = ("1", "2", "3"); my $bar = "5"; my $x = $bar / scalar(@ar_foo); 

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






This is the frame body I was using:

our $frame_body = $mw->Frame(-background => $color_theme_bg, -foreground => $color_theme_fg)->pack(-side => 'top'); 

And I have many widgets like labels, dropdowns, buttons, etc... within that frame like below:
 $frame_body ->Label( -text => "@_", -font => $arial_font, -foreground => $color_theme_fg, -background => $color_theme_bg, -highlightthickness => 0, -takefocus => 0, -relief => "flat", -justify => 'center', )-> grid( -column => $mw_col_ctr, -row => $mw_row_ctr, -sticky => "nsew", ); 

May someone help me the best way to apply a "vertical scroll bar" on the right side of this frame?

Its also nice if automatically adjust incase I manually resize the window. 😀

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




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


Is there a way to replace accented characters by their plain version, something like

tr/ûšḥ/ush/?

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



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



Is it possible to display an image to the user, without loading all the trappings of a whole widget / event-loop environment like Prima, Tk, Wx, Win32::GUI, etc?

Specifically, I want something simple that I can execute in a BEGIN block to display a splash image to the user while the rest of the application is compiled and initializes, which takes about 5-10 seconds. The program in question is a perl Wx application running under MS Windows.

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




Vim highlights subs with a signature params as red/orange to alert you it's incorrect. Now that Perl actually supports signatures and this is no longer a syntax error I need to find a way to disable this. This is really a Vim question, but I'm sure some other Perl nerd out there has run into this before me.

Has anyone figured out how to disable this "warning" in Vim?

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






A quick demo I threw togetherI threw together a quick proof of concept for myself writing out a very simple Entity Component System (ECS) and implementing the flocking simulation on top of it. I liked how it came together so well I wrote some prose around it and decided to share.

Note: this is using features from the soon-to-be-released 5.40.0 (RC1 dropped last Friday).

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




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



Hi, I recently got an offer for Senior SWE (current title at my company now) for a company that heavily utilizes Perl. I was wondering if folks from this community could offer some insight on what it's like working with Perl and also what, if any, potential long-term career implications are of becoming a Perl developer? Particularly I'm worried of pigeon-holing myself since Perl is not as heavily used in todays age and this company does not make use of modern cloud tools and deployments.

I am a Java developer (5 YOE) at a enterprise software company that is deployed in GCP. We are pretty regularly adopting new technologies so I'm gaining some valuable and relevant industry experience here but I am looking for a change and more opportunity to lead projects and mentor junior engineers.

The company seems good, great WLB, I liked the manager, and with the bonus (base is roughly the same) it would be about a ~8% TC increase plus a lot more stock (monopoly money, private RSUs).

Does anyone have experience transitioning from a Perl based company to a cloud based company with a more modern tech stack? Is this a backwards direction for me, should I continue with my Java development and instead look for opportunities that will offer more marketable skills?

Any input is appreciated, thank you for reading.

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




I've been trying to debug an issue for 3 days now, am getting nowhere, and am about to headbutt my laptop. If anyone's done any heavy lifting with Net:DBus then, for the sake of my laptop, I'd really appreciate the help!

Problem description: I have a hash table with a bunch of keys. The values relating to those keys are of different types (as in, I've cast them to dbus types). So:

my $testhash = {}; $testhash->{"xesam:albumArtist"} = [dbus_string("Tom Waits")]; $testhash->{"xesam:album"} = dbus_string("Mule Variations"); $testhash->{"xesam:trackNumber"} = dbus_int32(1); $testhash->{"xesam:artist"} = [dbus_string("Tom Waits")]; $testhash->{"xesam:title"} = dbus_string("Big in Japan"); $testhash->{"mpris:artUrl"} = dbus_string("file://mnt/storage/Music/mp3/Tom Waits/Mule Variations/folder.jpg"); $testhash->{"mpris:length"} = dbus_int64(64182857); $testhash->{"mpris:trackid"} = dbus_object_path("/0"); $testhash->{"xesam:url"} = dbus_string("file://mnt/storage/Music/mp3/Tom Waits/Mule Variations/01 - Big in Japan.mp3"); 

I've created a DBus service, and have successfully implemented a method that returns that hash table ($IFACE is the interface name I'm using for all of my test methods):
dbus_method("ReturnDynamicHash", [], [["dict", "string", ["variant"]]], $IFACE); sub ReturnDynamicHash { my $self = shift; print "Object: ReturnDynamicHash called.\n"; my $return = {}; my @keys = keys(%{$testhash}); my $count = scalar(@keys); if ($count) { foreach my $key (@keys) { $return->{$key} = $testhash->{$key}; } } return $return; } 

As a DBus method, this works perfectly:
% dbus-send ....... .ReturnDynamicHash array [ dict entry( xesam:trackNumber variant int32 1 ) dict entry( mpris:trackid variant /0 ) dict entry( xesam:albumArtist variant array [ Tom Waits ] ) dict entry( xesam:album variant Mule Variations ) dict entry( mpris:length variant int64 64182857 ) dict entry( xesam:url variant file://mnt/storage/Music/mp3/Tom Waits/Mule Variations/01 - Big in Japan.mp3 ) dict entry( mpris:artUrl variant file://mnt/storage/Music/mp3/Tom Waits/Mule Variations/folder.jpg ) dict entry( xesam:artist variant array [ Tom Waits ] ) dict entry( xesam:title variant Big in Japan ) ] 

However, the interface I'm implementing requires that a DBus Property return that hashtable, not a method:
dbus_property("StaticHashProperty", [["dict", "string", ["variant"]]], "read", $IFACE); sub StaticHashProperty { print "Object: StaticHashProperty accessed.\n"; my $return = {}; my @keys = keys(%{$testhash}); my $count = scalar(@keys); if ($count) { foreach my $key (@keys) { $return->{$key} = $testhash->{$key}; } } return $return; } 

and this doesn't work.

From the dbus-send client I get

Error org.freedesktop.DBus.Error.NoReply: Remote peer disconnected 

and from the Perl server stderr i get:
dbus[93409]: Array or variant type requires that type array be written, but object_path was written. The overall signature expected here was 'a{sas}' and we are on byte 4 of that signature. D-Bus not built with -rdynamic so unable to print a backtrace Aborted (core dumped) 

Now, this error is coming from libdbus itself, not the Perl wrapper (though could of course still be a bug in the Perl module that's causing the error). It seems to have entirely the wrong signature ( a{sas}, not a{sv} as defined above the Property method) and therefore appears to be complaining that the type of one of the values is wrong (each time I run it I get a slightly different error; I think it's deducing the signature from the first key-value pair it pulls from the hash and assumes they should all be the same - so if the first pair it pulls has a uint64 value, then it complains that the next pair doesn't also have a uint64 value).

Since the Method works I know Net::DBus can handle these sorts of return values, but for some reason, as a property, it just isn't working. I also know that other applications do implement this interface, including this Property, successfully, so I know this isn't a limitation of DBus.

I've been looking at the code in Net::DBus that handles serialization, assuming there must be some difference between how Properties and Methods are handled, but can't see anything obvious.

Anyone? Any idea? Literally anything at all? Thank you!!!!!

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



The following is a quick ramble before I get into client work, but might give you an idea of how AI is being used today in companies. If you have an questions about Generative AI, let me know!

The work to make the OpenAI API (built on Nelson Ferraz's OpenAPI::Client::OpenAI module) is going well. I now have working example of transcribing audio using OpenAI's whisper-1 model, thanks to the help of Rabbi Veesh.

Using a 7.7M file which is about 16 minutes long, the API call takes about 45 seconds to run and costs $0.10 USD to transcribe. The resulting output has 2,702 words and seems accurate.

Next step is using an "instruct" model to appropriately summarize the results ("appropriate" varies wildly across use cases). Fortunately, we already have working examples of this. Instruct models tend to be more correct in their output than chat models, assuming you have a well-written prompt. Anecdotally, they may have smaller context windows because they're not about remembering a long conversation, but I can't prove that.

Think about the ROI on this. The transcription and final output will cost about 11 cents and take a couple of minutes. You'll still need someone to review it. However, think of the relatively thankless task of taking meeting minutes and producing a BLUF email for the company. Hours of expensive human time become minutes of cheap AI time. Multiply this one task by the number of times per year you have to do it. Further, consider how many other "simple tasks" can be augmented via AI and you'll see why it's becoming so powerful. A number of studies show that removing many of these simple tasks from people's plates, allowing them to focus on the "big picture," is resulting in greater morale and productivity.

When building AI apps, OpenAPI::Client::OpenAI should be thought of as a "low-level" module, similar to DBIx::Class. It should not be used directly in your code, but hidden behind an abstraction layer. Do not use it directly.

I tell my clients that their initial work with AI should be a tactical "top-down mandate/bottom-up implementation." This gives them the ability to start learning how AI can be used in different parts of their organization, given that marketing, HR, IT, and other departments all have different needs.

Part of this tactical approach is learning how to build AI data pipelines. With OpenAI publishing their OpenAPI spec, and with Perl using that, we can bring much of the power of enterprise-level AI needs to companies using Perl. It's been far too long that Perl has languished in the AI space.

Next, I need to investigate doing this with Gemini and/or Claude, but not now.


Note, if you're not familiar with the BLUF format, it's a style of writing email that is well-suited for email in a company that is sent to many people. It's "bottom-line up front" so that people can see the main point and decide if the rest of the email is relevant to them. It makes for very effiicient email communication.

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



Hi all,

Nelson Ferraz has been working with generative AI for a while. I've started collaborating with him on his OpenAI modules. He wrote a module named OpenAI::API, but it required manually writing the code for all of the behavior. With the size of the OpenAI API, the rapid evolution, of said API, the birth of new models and the deprecation of old models, this approach turned out to be unmaintainable.

Thus, that module was deprecated in favor of Nelson's OpenAPI::Client::OpenAI module. Throw the 13K+ lines OpenAPI spec for OpenAI at it and it just works. Further, the module is pretty much a single Perl class rather than a bunch of hand-crafted code.

CPAN authors know it can be hard to keep modules up-to-date (mea culpa, mea culpa!) and this module is no exception. I need this module so I offered to collaborate and created a PR to update it to version 2.0.0 of the OpenAI spec. It now passes all the tests (for those wondering, you need an OpenAI key and it costs $0.04 USD to run the test suite).

In trying to build a Whisper pipeline for that, I found that I couldn't. There was a PR for Whisper support for the older module, but for the newer one, I can't figure out how to get it to issue a request with multipart/form-data support. I've noted the issue in the PR.

If anyone would like to see OpenAI support for Perl, we would dearly love to collaborate with you to make this happen.

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