68,313 questions
-3
votes
2
answers
180
views
Regex to match all but this pattern [closed]
I have filenames with this pattern [a-zA-Z0-9]{10} and .txt extension. They might also contain a pattern like this [super] and it could be either before or after [a-zA-Z0-9]{10} with '_' separating ...
0
votes
2
answers
118
views
How to execute code in response to uncaught exceptions
In some perl code I'm evaluating $v1 $op $v2 to make sure the result is valid and the program does not abort.
However when $op eq '/' and $v2 == 0 I noticed that a user-defined die handler is called (...
-5
votes
1
answer
97
views
Why does OpenAPI output validation fail for an endpoint but not for others?
I want to create an asynchronuous OpenAPI interface. Async jobs return a 202 and a location header to query later.
This is my OpenAPI document:
---
components:
headers:
JobLocation:
...
Tooling
3
votes
5
replies
107
views
Why is this proxied Mojolicious request much much slower than directly accessing the upstream server?
I am trying to implement a Mojolicious application that (also) acts as a proxy in front or rclone serve.
To that purpose I am trying to get Mojolicious to act as a proxy, and request from rclone serve ...
Advice
2
votes
7
replies
175
views
Perl library to create static HTML
Long story short I have written my own custom HTML template system that I am very happy with. However I have done that with manually concatenating HTML tags, and it is a bit messy. There has to be a ...
3
votes
2
answers
215
views
Is `use source::encoding "ascii";` implied by `use v5.42;`?
According to the new source::encoding pragma's documentation,
use source::encoding 'ascii' is automatically enabled within the lexical scope of a use v5.41.0 or higher.
To me, this means that
use v5....
7
votes
1
answer
140
views
Getting import errors for a symbol I'm not requesting
I'm running into a weird import error message while trying to create a commandline tool that references packages within a Perl web application. The web application itself is working fine. I can ...
2
votes
2
answers
110
views
Perl XML::LibXML and Storable equals segfault?
When using the perl library Storable to store and retrieve XML::LibXML document objects, I get a segmentation fault. Specifically, once I use the LibXML routine findnodes. My question is: why, and is ...
5
votes
2
answers
139
views
How to more nicely pull all values from hash that aren't a given key?
I know how to get all of the values of a hash given a set of keys:
use strict;
use warnings;
use DDP;
my %h = (
a => 1,
b => 2
);
my @v = @h{a,b};
p @v; # ( 1, 2 )
However I'm not sure ...
4
votes
2
answers
140
views
Two nested while loops on same array become infinite (they shouldn't)
I have a minimal working example of two nested while loops on the same array @g:
#!/usr/bin/env perl
use 5.042;
no source::encoding;
use warnings FATAL => 'all';
use feature 'say';
use autodie ':...
2
votes
2
answers
161
views
Split hash by array value
If there's a hash where one of the values is an array, what's the shortest way to split into an array-of-hashes (AoH) for each array value that keeps all the hash keys and values, except for replacing ...
2
votes
2
answers
127
views
Substitute if not in group of characters
How can I substitute every character that is:
not WORD (a-z, A-Z, 0-9) and also
not minus (-) and also
not hash (#)
to underline (_)
e.g.
"aB-09 !#" => "aB-09__#"
&...
1
vote
0
answers
91
views
Problem with mn_def_pars() function in PDL::Minuit
This package of the Perl Data Language
https://metacpan.org/pod/PDL::Minuit
When I run only the parameter definition part of the example program:
use PDL::LiteF;
use PDL::Minuit;
mn_init(\&$chi2, {...
2
votes
3
answers
175
views
How to properly replace long strings in Perl
Let's say I want to replace every occurrence of 12345 in file1 with the contents of file2. The following code works:
use strict;
use warnings;
local $/;
open my $fh, 'file1' or die "$!";
...
2
votes
1
answer
145
views
How do you decode a JSON boolean to a Perl boolean?
I would like the following code to round-trip properly on Perl ≥5.36.
❯ perl -MCpanel::JSON::XS=decode_json,encode_json -Mbuiltin=false,true -MDevel::Peek=Dump -E'
say Cpanel::JSON::XS->VERSION;...
1
vote
4
answers
249
views
Multiple replaces between markers but not outside them
To avoid some confusion and questions, I changed the new string to "letters", so it would not match "text", so to avoid infinite loops.
I work under Windows, with the perl provided ...
3
votes
1
answer
104
views
Why is AnyEvent slowing down or leaking memory?
While writing a new Perl module which was capable of using AnyEvent, my benchmarking tests showed that it was slowing down dramatically over time. Turning off AnyEvent cured the problem, which ...
2
votes
3
answers
148
views
When setting pattern property from a string in JavaScript, how to preserve the backslashes?
Related to Properly simulate "pattern" attribute with javascript:
How do I set an input pattern using JavaScript?
when I try element.pattern = 'a\S' (as a trivial example), then the pattern ...
-2
votes
1
answer
167
views
How can I tell if lighttpd is running on Debian 13? [closed]
My task was to port debian12 to debian13. In debian13 I noticed that the website was behaving differently with Perl v5.40.1. I found out that the following line returns different values on different ...
-2
votes
2
answers
104
views
How to use Perl `eval` to build a closure that executes the command in a string
In a CGI script that processes arrays of strings the user can supply for each field whether to match a string there or not.
If all user-specified criteria are fulfilled, the specific array should be ...
2
votes
1
answer
87
views
Disable Perl warnings for call to remote function
I'm defining some tests for a library I'm using. One of my tests is calling the code in such a way that it produces warnings, which is expected. However, I'd ideally like to suppress these warnings ...
0
votes
0
answers
80
views
Par:Packer: "Failed to execute temporary parl" when try to pack a .pl file to exe
I try to pack a .pl file to executable on windows,
I have strawberry-perl-5.40.2.1-64bit-portable and par:packer installed, also Tk is installed.
But it keep report error when execute pp -o a.exe a.pl
...
0
votes
1
answer
117
views
Packaging two scripts with system dependencies for NixOS deployment?
In my quest to get to know Nix and NixOS better, I'm going to try moving a small utility I have onto my NixOS server. There are two components to this utility:
A Perl script, which requires both (a) ...
2
votes
2
answers
189
views
Match pattern `\S` except when part of another pattern (ANSI escape)
I want to know whether the input contains any non-space as in \S. However, the input may contain ANSI VT escape sequences (Wikipedia) for text color and style, which do match \S (even the ESC code ...
2
votes
2
answers
179
views
How does interpolating a Perl constant into a string work?
I've just come across such usage of Perl constants:
use strict;
use warnings;
use constant PI => 4 * atan2(1, 1);
print("The value of PI is: ${\PI}\n"); # The value of PI is: 3....
5
votes
6
answers
519
views
Regex to match two consecutive dots but not three [duplicate]
I'm looking for a Perl regex that matches two or more consecutive dots unless there are three dots.
These strings should match:
Yes.. Please go away.
I have the ball..
In this case....I vote yes.
...
1
vote
1
answer
70
views
Bugzilla set reporter on creating Bug via WebService [closed]
I am creating a Bug on Bugzilla 5.2+ via rest-API. I try to achieve to set the reporter to a known Bugzilla user which differs from the used API-User.
I already tried that by creating an Extension.pm ...
-1
votes
2
answers
147
views
Connect to Snowflake OAuth Perl
since Snowflake is switching to MFA, I need to change some perl code to use access tokens.
Just doing something simple like this:
my $username = '';
my $pwd ='';
my $dbh = DBI->connect($dsn, ...
2
votes
1
answer
153
views
Why is Perl interpolating variable in single-quoted string?
Consider the following Perl script:
#!/usr/bin/perl
foreach(split '$$', 'A$$B'){ print; }
print "\n";
foreach(split '\$\$', 'A$$B'){ print; }
print "\n";
Given the well-known ...
-2
votes
3
answers
126
views
Replacing repeated arbitary characters with reg expression [closed]
Original data contains 4 times repeated characters, seperated by a space. For example,
code2 1 1 1 1 7 7 7 7 10 10 10 10 eq
code9 a a a a tpp1 tpp1 tpp1 tpp1 es
I'd like to add suffix to pairs using ...
-1
votes
1
answer
68
views
How to disable a single menu item in Perl/Tk menubar?
The following code creates a menu list called "User Selection" with four menu items: "Save", "Save As", "Load, and "Load From":
my $userselectedmenuitems = ...
-2
votes
4
answers
188
views
Problem when using `/^([^\n]*?)(\n)(.*)$/m` to match multi-line string
I have a problem I don't understand:
Given a string consisting of multiple lines like this:
DB<5> x $token
0 'ACCOUNT_CHANGED = "20250728081545Z"
ACCOUNT_CHANGED_T = "...
0
votes
2
answers
183
views
Does $dbh->prepare() provide any performance benefits for MySQL access?
The DBI docs on prepare() state that it's behaviour differ for various drivers:
Drivers for engines without the concept of preparing a statement will
typically just store the statement in the ...
0
votes
2
answers
132
views
Perl and Postgresl table name with dash
This line works fine under linux :
PGPASSWORD=***** psql --username=**** -h ***** -d **** -p **** -P pager=off -t --csv -c "select \"Nom\", \"Path\" from \"vVMware-Vms\&...
2
votes
2
answers
156
views
Perl decode_json "Wide character in subroutine entry" warning
I'm trying to read a json file which contains Vietnamese text.
I tried using decode_json with in-file string and it works well.
use strict;
use warnings;
use JSON;
binmode(STDOUT, ":encoding(...
0
votes
1
answer
146
views
split in void context worked in old perl, misbehaves in new
I found some old code that does this:
while(<IN>) {
chomp;
split;
if ($_[0] eq "junk") { ... }
The code works presuming pre-5.12 split in void context behavior:
$ /depot/perl-...
-1
votes
1
answer
82
views
Perl: IPC::Run escaping problems with special characters, commands not working
I am having problems running commands using IPC::run with special characters, in my current case ' and *
The used commands:
apt-get -y --allow-unauthenticated -o Dpkg::lock::timeout=0 install /tmp/...
-4
votes
2
answers
140
views
Installing par-packer under Cygwin: Perl version mismatch woes
I am trying to get par-packer running under Cygwin and having problems with Perl version mismatch. After installing and trying to run, I get this error:
bin > pp -o ehive_decode.exe myscript.pl
...
-2
votes
2
answers
122
views
Perl `gv`module: "No matching function for overloaded 'edge'
The manual page for the Perl gvmodule (graphviz) states:
New edges
Add new edge between existing nodes
edge_handle gv::edge (tail_node_handle, head_node_handle);
...
1
vote
4
answers
227
views
Understanding alternation branches and the "branch reset" extension
When using alternation with captures, I've often been somewhat puzzled by how it actually works, in particular why I would often get void (undef) match entries which I then have to discard by ...
4
votes
1
answer
117
views
Why doesn't Perl warn about using `$a` outside of sort block anymore?
I wrote some program for Perl 5.26.1, using strict and warnings.
So after some tests without a message I thought it's OK.
But when I ran the program wth older Perl 5.18.2, I suddenly got a warning ...
0
votes
2
answers
131
views
Check the name of an output file for proper permissions
A have a question similar to Perl: Testing that a file is actually writable as opposed to checking file permissions:
In a program I have an option to specify a required output file, and I want to ...
4
votes
1
answer
258
views
why is Perl File::Map so slow compared to File::Slurp?
I thought I'd try using mmap to search a multi-gigabyte file without running out of memory. I tested on a file that did actually fit and the File::Slurp version took less than a minute but the File::...
2
votes
2
answers
101
views
Why can't I embed a g modifier within a regex pattern?
my $modifiers = 'i';
my $string = "abcabc\n";
$string =~ s/(?$modifiers)B/Z/;
print $string;
$modifiers = 'g';
$string =~ s/(?$modifiers)a/q/;
print $string;
The first regex works and ...
-6
votes
2
answers
250
views
Problems joining string content [closed]
How can I join string content in Perl?
my $string = $q->param("us1"); # this is what entered +book +dog +cat
print join(',', $string), "\n";
This is the output I want:
"+...
3
votes
3
answers
158
views
Extract multiple tabular data from spark logs
I'm trying to extract the tabular data from apache pyspark logs using a perl one-liner.
Below is the sample file log and there are 3 tabular output from the spark output:
24/06/19 01:00:00 INFO org....
1
vote
3
answers
121
views
Opening a pipe generates a taint error, but there appears to be no tainted data
This statement:
open(FIND, "/usr/bin/find /home/steve -type f -print |");
gives:
Insecure $ENV{PATH} while running with -T switch
I got around it by setting
$ENV{PATH} = '/usr/bin';
but ...
0
votes
3
answers
115
views
How to clone a Perlbrew install
I use Perlbrew to manage local Perl binary installs. I'd like to clone the current install so that I can test out a new CPAN module, and then revert if I don't like the module. I'd rather not wait the ...
1
vote
2
answers
94
views
How to determine the arity of a ≥5.20 signatures method?
Problem shown below:
use 5.036; # signatures
use strictures;
package Foo {
use Moose;
sub quux($self) { ... }
}
package Big::Quux {
use Moose::Role;
sub quux($self, $another) { ... }
...
1
vote
1
answer
67
views
Tk text widget - why does deleteTextTaggedWith fail?
my $mw = MainWindow->new;
my $text = $mw->Text->pack;
$text->insert('end', 'hello world', 'mytag');
$text->deleteTextTaggedWith('mytag');
MainLoop;
The deleteTextTaggedWith causes:
...