68,317 questions
-2
votes
1
answer
44
views
output Perl executable with all modules, and specific Perl version
I have a script that starts like this:
use strict;
use feature 'say';
use warnings FATAL => 'all';
use autodie ':default';
use Term::ANSIColor;
use Cwd 'getcwd';
use SimpleFlow qw(task say2);
use ...
Advice
2
votes
2
replies
100
views
Perl: sort of Lamda-terms
I am sure there is some "Perl magic" that makes my code much shorter.
my %m = ("a" => 1, "b" => 12, "c" => "33");
my $str = "";
for ...
Advice
1
vote
2
replies
99
views
Perl: String counter
I have a maximum number and a separator - e.g., max. of 7 and "," for separator.
I want a string from 0 to this max with a separator.
my $str = foo (7, ",");
# $str should be "...
1
vote
0
answers
84
views
parallel::forkmanager not working when using dbi
I've written a Perl script where I am able to successfully use the parallel::forkmanager module. I setup a simple script which has 6 entries in an array and takes 3 at a time, just prints the number ...
Best practices
0
votes
10
replies
141
views
Print results of multi-lined substitutions only
Web search somehow do not find relevant results. And perl docs too (e.g. seems there is no 'selection operator'). I have a large text file and want output of results of global substitution, but not ...
4
votes
2
answers
101
views
How to use fcntl when only a file desciptors is available?
In Perl on Linux, I want to check the File status flags of an OS file descriptor number without knowing which Perl file handles, if any, use that file descriptor (the fd might even have been inherited ...
-1
votes
0
answers
49
views
How to add_header from inside a SpamAssassin plugin?
I'm working on a SpamAssassin plugin, which would submit the text of a suspected email to AI (via HTTP POST) and process the response. The response is expected to contain a one-word verdict (one of &...
1
vote
1
answer
115
views
File is empty after writing to it
I'm working on a little wikilink to Markdown link converter with Perl. This is the conversion code:
foreach my $idx (0 .. $args) {
if (-e -f -r -w $ARGV[$idx]) {
my $file_name = $ARGV[$idx];
...
Best practices
2
votes
6
replies
83
views
Best way to deploy an Perl Mojolicious web app to an containerized production environment
Which the best way for deploying an Perl Mojolicious web app to an containerized production environment like Docker or Kubernets:
# one process per pod
/script/my_app daemon
or starting an more ...
-2
votes
1
answer
91
views
Hash reference at package level not visible to subroutines [closed]
Trying to write some Perl code, wherein a hash reference is defined and some functions that can work with that hash reference.
The following code works
package test {
sub run {
my $...
4
votes
4
answers
228
views
Modify numeric values with Perl one-liner
I would like to use a Perl one-liner to modify numeric values in a text file. My data are stored in a text file:
0, 0, (1.263566e+02, -5.062154e+02)
0, 1, (1.069488e+02, -1.636887e+02)
0, 2, (-2....
2
votes
2
answers
88
views
Redirecting STDERR output using Perl and exec
In Perl under Unix (HP-UX and Linux) I start instances of a program and redirect their outputs to files. I fork without problem, close the old STDOUT and STDERR, open a file to use as STDOUT, then ...
3
votes
1
answer
67
views
Excel::Writer::XLSX chart custom labels not working
I've gone through the Custom Data Labels documentation carefully, and reduced down to a simple example:
#!/usr/bin/perl
use strict;
use warnings;
use Excel::Writer::XLSX;
my $workbook = Excel::...
1
vote
3
answers
200
views
JSON parse array of data
I have the following program with JSON:
use strict;
use warnings;
use Data::Dumper qw( );
use JSON qw( );
my $json_text = '[
{
"sent": "2026-01-16T17:00:00Z",
"...
0
votes
1
answer
149
views
How to avoid "Not a HASH reference at ..." in regex like "qr/^${\CONSTANT}{3,}$/"
In a script I'm using constants (use constant ...) to allow re-use ion actual regular expressions, using the pattern from https://stackoverflow.com/a/69379743/6607497.
However when using a {...} ...