Skip to main content




SlapbirdAPM now generically supports DBI!Hey friends, a few weeks back we introduced SlapbirdAPM (an open-source Perl application performance monitor), and received some great feedback from the community!

Today we'd like to announce that you are now able to track DBI queries in your applications (only available for Dancer2 and Mojolicious for now), regardless of your database, ORM, etc. Here's what it looks like! You can see the dancer2 code that generated these queries here.

https://preview.redd.it/l2jvz1bne8nd1.png?width=1353&format=png&auto=webp&s=c6e4195ecf0ff75ab632e8ce32dc86308d69a691

This is just one of the many monitoring features provided by SlapbirdAPM, hopefully you find them as useful as we do! And a reminder we have a *forever* free tier available for everyone!

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



Check out the latest version of String::Util and let me if you have any suggestions for other string based funcions I can add.

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



Since the language formerly known as Perl 6 has officially gone off on its own, has there been any effort to implement a true Perl 5 successor?

In my opinion, Raku tried to do too much with the syntax itself, scaled Perl's flexibility to infinity, and made itself unusable.

Perl 5 does not need much for it to become a "modern" language. Instead of extending the flexibility of the syntax, the direction for Perl 6 should emphasize standardizing core utilities to facilitate integration with modern workflows.

- Package/module management and import/export could benefit from streamlining
- Stronger LSP and debug/error tooling (Rust has spoiled me)
- "Prettier" auto-formatting for source code (For those 30yo system scripts, you know the ones I mean)

What would be on your wishlist?

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



Just click the link: https://shell.cloud.google.com/?pli=1&show=ide%2Cterminal

System perl is 5.34. 5.40 work if you skip man::db

perlbrew install --noman -n perl-5.40.0 

It was easy to run a Dancer2 app and view via "Web Preview"

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



I've been writing an example web application using Dancer2.

Well, I say I've been writing it. Actually, I've been specifying it and GitHub Copilot Workspace has been writing the code. It has been interesting (and, rather more successful than I expected).

I shall continue with the experiment.

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




Hi. I want to update a perl module (Spreadsheet::ParseExcel) from v0.65 to v0.66. I've transferred the module on the target machine. However, "make", "dmake", and "gmake" are all not available as methods to install this module, neither is cpan. The machine is completely isolated from the internet and absolutely cannot be modified to connect. How would I go about updating such a module without using the usual installation methods? Essentially, my question is that can I replace the ParseExcel(.)pm file and ParseExcel folder manually with no issues? Appreciate any help.

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



Setup:

Perl v5.40
AlmaLinux release 9.4
Nginx
Spawn-fcgi

First of all I know there are better ways than using Spawn-fcgi and we are looking at some refactoring; until then we are seeing child processes forked with Spawn-fcgi die from time to time and I have not been able to figure out a way on how to catch them / troubleshoot what is going on/killing them

I have a big try/catch clause in the moment the call comes in

while ( my $q = CGI::Fast->new() ) { eval { 

but its not really catching anything when the processes die. I do have the process ids but I cannot really correlate them to anything in the nginx logs. At the same time I would not expect for nginx to "kill" any fcgi processes or could it?

Any pointers much appreciated.

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



In the latest Canonical announcement for Ubuntu 24.04.1 availability, Perl is mentioned among a small list of other programming languages:

As the target platform for open source software vendors and community projects, Ubuntu 24.04 LTS ships with the latest toolchains for Python, Rust, Ruby, Go, PHP and Perl, and users get first access to the latest updates for key libraries and packages.

It’s also mentioned as well in the “Ubuntu for developers” use case:

Ubuntu ships with the latest toolchains for Python, Rust, Ruby, Go, PHP and Perl, and users get first access to the latest updates for key libraries and packages.

Note they call all those “cutting-edge software”

This is quite unusual in the last few years, and the initial announcement for Ubuntu 24.04 in April didn’t mention it.

What is going on and what do you think?

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






I wanted a quick way to convert 255.255.255.252 -> 30 and other netmasks... this works!

$mask =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ or next;
$cidr = 32 - (log(256-$1)+log(256-$2)+log(256-$3)+log(256-$4)) / log(2);

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



I have been working as a freelance developer for the last 9 years, about 80% of that has been PHP based.

I just landed a big, possibly once in a lifetime client that has a just about 30 year old code base.

I am completely new to perl, I have done some crash course reading to understand syntax, operators etc.

For the most part I can read and understand the code, on my third day I discovered the architecture.

It's basically 4 systems in one root folder, each of those systems basically contain a package file and a index file which seems to contain the entire system within that that file.

There are references to templates (Template Toolkit) and other things outside the file but for the most part all the business logic is one file.

While going through this I realized there was non of the standards I had been accustomed to in PHP and other projects.

Archaic routing (basically none), the closest thing to a function an if statement that else ifs it's way down thousands of lines of code.

So I have some ideas to implement routing, modularity and probably convert the conditions to sub routines (we call these functions in my old club)

It's like take a journey back in time to an era that I was not around for.

With that being said, knowing what you know, what suggestions, secrets, tips or warnings would you be willing to share?

Edit: Great community! Who says perl is dead 😀 so many great resources, thank you so much! I will be spending a lot more time on this sub!

submitted by /u/Mowntain-Goat8414
[link] [comments]



When DEV, STAGING, and PROD are on the same box - T. Alex Beamish - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]




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




Glue - Lee Johnson - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]


Hi all! I have a bug in my script I can't locate and I'm sure it must be some silly thing.

I am using a SQLite database with a contacts table that includes a field for the date in which the contact was added or edited. This is a DATE type field defined as "editado" date NOT NULL.

I search for a group of contacts by doing this (nomap is a string field with name and lastname):

sub cntSearch( $srch ) { my @result = (); my $tosrch = $srch; $tosrch =~ s/([\\%_'"\[\]])/\\$1/g; # LIKE no admite $dbh->quote() $sth = doSQL( "SELECT * FROM contactos WHERE nomap LIKE '%$tosrch%' ORDER BY nomap" ); while ( $hr = $sth -> fetchrow_hashref() ) { utf8::decode( $hr->{nomap} ); push @result, $hr; } return @result; } 

At this point, if I read $hr->{editado}, I get the string I want (a date in the YYYY-MM-DD format). But when I do this:
my @cntlist = cntSearch( $srch ); for ( @cntlist ) { my ( $codigo, $nomap, $ref, $editado ) = ( $_->{codigo}, $_->{nomap}, $_->{referencia}, $_-->{editado} ); } 

the variable editado gets the value 1.

The actual code is more complex but this is the gist of it and I think the other stuff is not related.

Any advice on this would be appreciated!

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



Perl was (and still) is used for system administration to this day. If you have professional system administration experience what have you seen Perl used for in sysadmin practices the most?

When would you recommend it? When would you not recommend it and what would be the alternativein which case?

Do you still see coworkers and yourself using Perl for such tasks. I ask because I'm confused as to how Perl stands up as a system admin tool compared to other options in modern times.

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






Perl KVM - Chad Granum - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]



This is my first attempt to create a Perl script.

This script is to convert Markdown files to plain text ones, with some "common" typographic substitutions.

When I finish it, it is assumed to work as follows:

  1. Single-hyphen dashes are replaced with three hyphens: that is, foo - bar is replaced with foo---bar
  2. Markdown-style italic is replaced with Org Mode-style italic: that is, foo *bar* baz is replaced with foo /bar/ baz
  3. Blank lines are replaced with first-line indents, that is:
    ``` FROM THIS This is a 500-character line of text.

    This is another 500-character line of text. ```

    TO THIS This is a 500-character line of text. This is another 500- character line of text.

  4. Lines are hard-wrapped at 72 characters, and additionally:
  5. Any single-letter word, such as "a" or "I", if it happened to be at the end of a hard-wrapped line, unless it is the last word in a paragraph, is moved to the next hard-wrapped line, that is:
    FROM THIS He knows that I love bananas.

    TO THIS He knows that I love bananas.

And now the first draft. Please don't laugh too loudly 😀

```

!/usr/bin/perl


perl -pi -e 's/ - /---/g' $1 # foo - bar to foo---bar perl -pi -e 's/*///g' $1 # foo to /foo/ perl -pi -e 's/\n{2}/\n /g' $1 # blank lines to first-line indents ```

The first two lines work fine.

But I really don't understand why the third line doesn't replace blank lines with first-line indents.

Also, maybe someone can point me to an existing Perl or Awk script that does all of this.

submitted by /u/No-Usual-9631
[link] [comments]



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


Per Context Catalyst Component - John Napiorkowski - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]


This is not Perl specific, but in our new era of this Perl economy everyone should be thinking about side-hustles and income streams. Perl is perfect for creating SaaS and other services because for efficient practitioners it presents the most efficient way to prototype a lot of things via the web.

For example, shared hosting is dirt cheap and supports cgi-bin; VMs on the cloud are also dirt cheap and you probably don't need more than a $5 instance to POC something that will be good enough to test interest. Knowing more about pricing models is part of that. This is an interesting article about SaaS pricing models, and know more about that is certainly part of creating paid services. Enjoy.

https://garrettdimon.com/journal/posts/data-modeling-saas-entitlements-and-pricing

* sorry the code examples in here are Python, but I think for this purpose we can look past that

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




Hi all! This is my first Perl script.

#!/usr/bin/perl use strict; use warnings; use Curses::UI; use Data::Dumper; use JSON; # Create the root Curses::UI object my $cui = Curses::UI->new(-color_support => 1); # Set up a signal handler to exit on Ctrl+C $cui->set_binding(sub { exit(0); }, "\cC"); # Create the main window my $win = $cui->add('window_id', 'Window'); # URL to fetch email address my $response = "https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=1"; # Variable my $email_address = ''; my $username = ''; my $domain = ''; my $formatted_email = ''; my $formatted_json = ''; my $formatted_inbox = ''; my $Id = ''; my $box = ''; # my $filename = '/home/ola/Work/Languages/Perl/curses-ui/1/TempMail-Curses-UI/file.txt'; # Calculate the center Y position based on the window height my $window_height = $win->height(); my $center_y = int(($window_height - 1) / 2); # Create $win->add( 'buttonbox_id', 'Buttonbox', -y => $center_y, -buttons => [ { -label => '< Get Random Email >', -onpress => sub { $email_address = `curl -sL $response`; chomp($email_address); $email_address =~ s/^\["(.*)"\]$/$1/; print $email_address; # Split the email into username and domain my ($username, $domain) = split('@', $email_address); chomp($domain); print "Username is: $username\n"; print "Domain is: $domain\n"; # Copy system("echo $email_address | xsel --clipboard --input"); # Write to file open(FH, '>', $filename) or die $!; print FH $email_address; close(FH); # print "Writing to file successfully!\n"; # Send test mail # system("perl SendMailTest.pl"); # Display the output in a dialog $cui->dialog( -message => "Random Email:\n$email_address\n Copied To Clipboard", -title => "Email Address", -buttons => [ { -label => '< OK >', -value => 1, -shortcut => 'o', } ], ); } }, { -label => '< Update Inbox >', -onpress => sub { # my $command_output = `curl -sL "https://www.1secmail.com/api/v1/?action=getMessages&login=2gqhd4oz4wb&domain=laafd.com"`; my $command_output = `curl -sL "https://www.1secmail.com/api/v1/?action=getMessages&login=$username&domain=$domain"`; chomp($command_output); $formatted_json = decode_json($command_output); $Id = $formatted_json->[0]->{id}; # Display the output in a dialog box $cui->dialog( -message => $formatted_json->[0]->{subject}, -title => "$Id = $formatted_json->[0]->{id}", -buttons => [ { -label => '< Fetch Mail Body >', -value => 1, -shortcut => 'o', } ], ); $Id = $formatted_json->[0]->{id}, # my $inbox = `curl -sL "https://www.1secmail.com/api/v1/?action=readMessage&login=2gqhd4oz4wb&domain=laafd.com&id=$Id"`; my $inbox = `curl -sL "https://www.1secmail.com/api/v1/?action=readMessage&login=$username&domain=$domain&id=$Id"`; chomp($inbox); my $formatted_inbox = decode_json($inbox); my $box = $formatted_inbox->{textBody}; # print Dumper($formatted_inbox); print $box; $cui->dialog( -message => $box, -title => "$Id = $formatted_json->[0]->{subject}", -buttons => [ { -label => '< OK >', -value => 1, -shortcut => 'o', } ], ) } }, ], -buttonalignment => 'middle', ); $cui->mainloop; 

This is a script to fetch a temp mail address from the API, then display the contents of its inbox.

Problem


Everything was working fine, but suddenly I'm getting an error about screen size. I am literally clueless at this point.

Error:


Your screen is currently too small for this application.

Resize the screen and restart the application.

Press <CTRL+C> to exit...

Info


Terminal has 45 lines and 189 coloumns, and is full screen.

This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-thread-multi

Curses::UI Version: INST_VERSION 0.9609

OS is Arch Linux

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



Lessons From an Idaho Potato Farmer - David Laulusa - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]



Fixing a fifteen-year-old curve fit bug submitted by /u/oalders
[link] [comments]


Signature named params · Pull Request #54 · Perl/PPCs submitted by /u/briandfoy
[link] [comments]



Hello friends,

Over the last 7 or so months I have worked with a very small team to build a performance monitor for the modern Perl web-application ecosystem. As of today, the project is now available to everyone via the free-tier only, later however, (a month or so) we will be opening up our priced tiers to business users who will most likely need more from the application.

Please feel free to check it out, and I look forward to hearing feedback!
https://slapbirdapm.com/r/perl/.rss
https://github.com/mollusc-labs/slapbird

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




Build a Better README - Jason A. Crome - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


From a discussion on Hacker News:

One particulary mnemonic collection of switches is -plane: perl -plane 'my $script'. -n and -p are mutually exclusive, but as -p overrides -n, it is easier to just remove -p if necessary.

Few other users in another discussion there mentioned -E -n -l -p options especially useful.

Is there anything really cool about -plane or -Enlp? Are they really somewhat a "Holy Grail" of running Perl scripts from the command line, and why?

submitted by /u/Impressive-West-5839
[link] [comments]



I thought I had seen somethink about this, but does Perl reserve a block of memory upon startup for user variables? Or are user variables always allocated when they are created/initialized with Newx, Newxz ?
From some benchmarks it seems that Perl does set some memory aside to avoid requesting memory from the OS all the time, and I thought I had seen some material about how to modify this "scratch space" but I could be very wrong or senile.

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



I have noticed the Perl Cookbook, 2nd Edition as an outstanding reference. How about the work Perl by Example, Fifth Edition? How does it compare? Would you recommend it as a reference as well?

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



Hi Everyone.

I am learning from the book "Learning Perl" and so far the journey is thankfully going great!

One thing noticed about Perl is that although the developer community here is smaller than other mainstream languages it feels very tight-knit. Is that just me or were you also drawn to Perl because of the strong community responsiveness to each other?

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



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


UUID::Tiny has a weird way of getting a random 32bit integer using 2x random 16 bit integers bitwise OR'd together:

sub _rand_32bit { _init_globals(); my $v1 = int(rand(65536)) % 65536; my $v2 = int(rand(65536)) % 65536; return ($v1 << 16) | $v2; }

Anyone know why you would do this instead of just: my $rand = int(rand(2**32));? Also why the modulus, isn't it redundant?

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