Skip to main content


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]



I forgot it was CPAN Day, but it still is CPAN Day in parts of the world so maybe you can get some CPAN housecleaning in. I use this day to delete old versions of my distributions from CPAN.

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





Playwright-Perl - George S. Baugh - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


I found a script from 2008 year, that renames files to random filenames:

```

!/usr/bin/perl

randomize the filenames for the photo frame

https://www.bulkrenameutility.co.uk/forum/viewtopic.php?t=114


$dir = $ARGV[0] || die "directory?\n"; chdir($dir) || die "chdir";

opendir(D, ".") || die "opendir"; @files = grep {/jpg/} readdir(D); closedir(D);

array shuffle from perl FAQ


srand; @newfiles = (); for (@files) { my $r = rand @newfiles + 1; push(@newfiles,$newfiles[$r]); $newfiles[$r] = $_; }

if ($#files != $#newfiles) { die "$#files != $#newfiles\n"; }

while ($old = pop @files) { $new = pop @newfiles; $new =~ s/p/r/; ! -f $new || die "won't overwrite $new - check the regexp\n"; print "$old -> $new\n"; rename $old, $new || warn "rename $old -> $new: $!\n"; } ```

If I run it as perl foo.pl ./, there is won't overwrite bar.jpg - check the regexp error. And if I run it as perl fo.pl ./bar.jpg, there is chdir at foo.pl line 7 error. How to make it work?

I have Perl 5.34.1 installed.

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



Abe Timmerman ABELTJE has passed away yesterday after a long fight with cancer.

A long time participant in what are now called Perl Toolchain Summits, he was co-responsible for setting up the Perl smoking infrastructure.

And was always a welcome guest at almost all YAPC::EU conferences, as well as many Dutch and Belgian Perl Workshops, and NLPM (Dutch PerlMongers) meetings.

He will be missed. R.I.P.

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




As a security engineer I am obsessed with building computer systems that are reliable and fault-tolerant. I was researching Erlang and Elixir to build servers that are designed that way. But others here mentioned Perl is used in production ready projects where availability of the system is key -- such as Amazon.

What are the pros and cons in using Perl to deploy production ready servers vs Erlang, Elixir, Golang, C++ and other common back end languages / frameworks?

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



Aside from the Perl project itself what were the Perl projects published that had a positive impact in the world--whether in the tech industry or even for hackers and hobbyists. I ask to better understand what Perl is and is not useful for.

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



So I came across a book named "Higher-Order Perl" which teaches how to apply functional coding concepts to complete tasks in Perl. Have you used the book's techniques in your production-deployed projects? If so how did the book's advice help?

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



Hi everyone. I am still researching how to benefit from Perl as a security engineer. I heard you can use Perl to test for security exploits in codebases? What have you used Perl for in he past? What did you find of most helpful for in your coding journey?

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




[aside] This is not a cross-post. Few days ago I asked the same thing on Stack Overflow, and there were several answers, but none of them works really perfect.)

I have a folder with the following files there:

1.mp3 1.mp3.mp4 1.mp4.mp3 1.txt 2.mp3 2.mp3.mp4 2.mp4.mp3 2.txt foo.mp3 foo.mp3.mp4 foo.mp4.mp3 foo.txt foo1.mp3 foo1.mp3.mp4 foo1.mp4.mp3 foo1.txt foo2.mp3 foo2.mp3.mp4 foo2.mp4.mp3 foo2.txt

Filenames like foo.mp4.mp3 mean that originally the file was MP4 and later converted to MP3.

I need to batch rename MP3 files there, so that their numbers will be padded with leading zeros, that is, 1.mp3 should be renamed 0001.mp3, 1.mp4.mp3 to 0001.mp4.mp3, foo1.mp3 to foo001.mp3, and so on.

Here are several attempts by other people:

  • rename -n 's/(\d+)/sprintf "%03d", $1/e' *.mp3
  • rename -n 's/(\d+)\.mp3/sprintf "%03d.mp3", $1/e' *.mp3
  • rename -n 's/(\d+)(\.mp3)/sprintf("%03d", $1) . $2/e or s/(\d+)(\.mp3)/sprintf "%03d%s", $1, $2/e' *.mp3
  • rename -n 's/(\d+)(\.mp3)/sprintf "%03d%s", $1, $2/e' *.mp3
  • rename -n 's/(\d+)(?=\.mp3)/sprintf "%03d", $1/e' *.mp3
  • and my own, doesn't work either: rename -n 's/(\d)(\.[^.]+)/sprintf "%03d%s", $1, $2/e' *

Maybe there is a Perl wizard here who could help me?

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



Hello Perl Community. I was trying to build a secure string library in C resistant to buffer overflow vulnerabilities when I realized parsing inputs matters. Perl is well known for string rendering. What books would you recoendnd to a proficient C coder that is trying to learn Perl to master the art of parsing and editing strings to avoid common security exploits?

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




Reasoning About the Rigor of Perl Programs - George Baugh - TPRC 2024 submitted by /u/briandfoy
[link] [comments]



#!/usr/local/bin/perl use v5.40; use Syntax::Operator::Matches qw( matches mismatches ); use Type::Tiny; my $x = "123"; my $y; my $z = 'abc'; if ( $x matches $z ) { say "1"; } else { say "2"; } 

Coded runs and compiles fine.

perltidy error

MacBook Pro 2021:lt administrator$ perltidy matches.pl matches.pl: Begin Error Output Stream matches.pl: matches.pl: 9: if ( $x matches $z ) { matches.pl: -- ^ matches.pl: found bareword where operator expected (previous token underlined) 

.perltidyrc
# PBP .perltidyrc file # Uncomment #-st to fully emulate perltidy -pbp -l=278 # Max line width is 78 cols -i=4 # Indent level is 4 cols -ci=4 # Continuation indent is 4 cols #-st # Output to STDOUT -b # Write the file inline and create a .bak file -se # Errors to STDERR -vt=2 # Maximal vertical tightness -cti=0 # No extra indentation for closing brackets -pt=1 # Medium parenthesis tightness -bt=1 # Medium brace tightness -sbt=1 # Medium square bracket tightness -bbt=1 # Medium block brace tightness -nsfs # No space before semicolons -nolq # Don't outdent long quoted strings #-icb # Break before all operators -wbb="% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x= matches" 

spent an hour on this without luck; is there anyway to make perltidy aware of the imported matches operator?

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



Is there a way to make a readonly blessed reference that detect attempts to modify it at compile time of the script? Package Readonly , Package Const::Fast and Readonly::Tiny die at runtime

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



Hi,

I have been programming in perl for the last 25 years but things have dried up with my long term set of clients recently. I see a lot of posts on here about how there is a huge amount of perl code out there and a need for experienced perl developers ... but I am struggling to find it. I used to go to jobs.perl.org but there hasn't been much there for ages. Upwork seems to have minimal perl projects, so I am a bit stumped. I was on LinkedIn for ages but it became too much of a spammer's paradise.

I'd really appreciate some tips on how to re-expand my client base in 2024!

Rob

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




Going nuts with this regex, looking for second pair of eyesThis works and returns several files:
```
my $image_name = quotemeta('Screenshot-2024-02-23-at-1.05.14');
my $files = $wac->get_all_files_in_dir($dir . '/uploads', qr/$image_name.*\.png$/);

```

This returns no files:
```
my $image_name = quotemeta('Screenshot-2024-02-23-at-1.05.14 AM');
my $files = $wac->get_all_files_in_dir($dir . '/uploads', qr/$image_name.*\.png$/);
```

Note the space in the file name before AM.

This also returns no files:
```
my $image_name = quotemeta('Screenshot-2024-02-23-at-1.05.14\s*AM');
my $files = $wac->get_all_files_in_dir($dir . '/uploads', qr/$image_name.*\.png$/);
```

I tried with and without quotemeta and with and without /Q /E to no avail.

Is it possible the space is some kind of invisible UTF8 character? This is driving me nuts.

**UPDATE:** I jumped on regex101.com and copied and pasted in the file name from the terminal and indeed there appears to be some kind of hidden character that is not whitespace:

https://preview.redd.it/icpdpzxj1gid1.png?width=828&format=png&auto=webp&s=1f78222cdd1d45bc1c5f39d0e48d04e7c57b3f74

Did a hex dump of the string:

00000000 53 63 72 65 65 6E 73 68 - 6F 74 2D 32 30 32 34 2D Screenshot-2024-

00000010 30 32 2D 32 33 2D 61 74 - 2D 31 2E 30 35 2E 31 34 02-23-at-1.05.14

00000020 E2 80 AF 41 4D 2D 31 30 - 32 34 78 36 39 38 2E 70 ...AM-1024x698.p

00000030 6E 67 0A ng.

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




Which way would you like to refresh the advisory data for CPAN::Audit? · briandfoy cpan-audit · Discussion #61 submitted by /u/briandfoy
[link] [comments]


submitted by /u/Active-Fuel-49
[link] [comments]



http://Direct Access to PDF Internals with PDF::Data - Deven Corzine - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


I try to use Perl's rename utility to translate filenames to lower case. I tried two different solutions, one from perldoc rename and another from Perl Cookbook:

  • rename 'y/A-Z/a-z/' ./*
  • rename 'tr/A-Z/a-z/ unless /^Make/' *.txt

But either version gives me an error because of complaining that file with such a filename already exists:

./fOoBaR.tXt not renamed: ./foobar.txt already exists

How to make it work?

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



While refactoring some code with the usual desire to improve/simplify, I came by this interesting example on S.O. that uses the dispatch table structure:

ref _ https://stackoverflow.com/questions/844616/obtain-a-switch-case-behaviour-in-perl-5


my $switch = { 'case1' => sub { print "case1"; }, 'case2' => sub { print "case2"; }, 'default' => sub { print "unrecognized"; } }; $switch->{$case} ? $switch->{$case}->() : $switch->{'default'}->(); #($switch->{$case} || $switch->{default})->() # ephemient's alternative 

Dispatch tables are powerful and I use them often.

Gabor Szabo offered a post with an example of given/when, but in the end he suggests just using the if/else construct.

given ($num) { when ($_ > 0.7) { say "$_ is larger than 0.7"; } when ($_ > 0.4) { say "$_ is larger than 0.4"; } default { say "$_ is something else"; } } 

ref _ https://perlmaven.com/switch-case-statement-in-perl5

= = =

Which approach do you prefer? Or do you prefer some other solution? Saying no to all the above is a viable response too.

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



Why? (It is on Linux and with utf-8)
perl -CADS -le 'print $ARGV[0]' -- -v=αβγ -v=αβγ perl -CADS -sle 'print $v' -- -v=αβγ αβγ 

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


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


Are there new modern alternatives to PerlNET? I am using a Perl game automation library whose ui is built with Wx using Perl bindings. I want to create my own UI using C#(WPF) so wanted to kno if there are existing solutions to this?

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



The Once and Future Perl - Damian Conway - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


If you have some time, read this post over at reddit

https://www.reddit.com/r/bioinformatics/s/lcxEeInCOS

Apparently Anaconda is ActiveStating people and this may very well prove to be a significant issue in the dominance of Python in certain data science fields. Bioinformatics is a very good example of a field that got addicted to Python and the reliance of Anaconda is coming back to bite (the post and the responses raise the prospect of nightmarish scenarios for other environment managers like conda-forge/buoconda). The immediate solution for dependency management is to dockerize everything, but many tools require individual docker containers. If you have to combine more than one of them, chances are that your path will not be a rosy one.

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



Although this StackOverflow question about "islands and gaps" is titularly about Perl, the SQL answers are very nice. Apparently this is a FAQ for SQL.

However, this has bugged me for years on the CPAN side, but never enough to make me really do anthing about.

I thought there was a Perl module that did this, and it was in the context of a usenet reader that would take a list of article IDs, such as 1, 2, 3, 4, 5, 7, 10, 11, 15 and return something like 1-5,7,10-11,15 as a more space-efficient store of all the articles you had read.

Every time I've looked I've stopped after 15 minutes because I get distracted and I've never really needed this except to answer someone else's question. I'm not asking how to solve this because there are plenty of algorithm tutorials out there. Surely this is on CPAN somewhere.

There are plenty of options to go the other way and to ask if a number is in one of the ranges.

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



Actually Portable Perl - Gavin Hayes - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


GitHub - PerlToolsTeam/github_workflows: Some useful (and reusable) GitHub Workflows submitted by /u/briandfoy
[link] [comments]


Party Like It's 19100+e^iπ - Curtis Poe - TPRC 2024 submitted by /u/briandfoy
[link] [comments]



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


Good afternoon, all. I have a Perl script that connects to a bunch of REST-based services via LWP::Simple. I'm running on MacOS (Perl v5.30). One of these services moved to be SSL-based. I've been struggling to find an appropriate library to use for SSL with Perl. These libraries require a certain amount of certificate management on my Mac -- and integration with Perl via environment variables or such -- and the instructions are generally sparse/obtuse. Can anybody help with this? I'm not looking to do anything particularly fancy. Just call a REST service via HTTPS. Thanks in advance for your help.

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



We need to be able to work with parquet files. It is a must.

For anyone cares a solution could me a native DuckDB driver. It is a pitty we do not have it.

George Bouras

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



I am following instruction to the t; both with CPANM and from source the install fails.
OPEN_SSL prefix is set as followed
export OPENSSL_PREFIX="/usr/local/opt/openssl@1.1"

Full error message here:
https://jumpshare.com/s/QMxo2rY1sf8j3nYGyEo8

Anyone able to help? Pulling my hair out.

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