Perl::Critic versus File::Path
1 direct reply — Read more / Contribute
|
by mldvx4
on Dec 05, 2025 at 11:50
|
|
|
Greetings O monks,
I have turned perlcritic --stern towards several scripts I have and encountered a question. The manual page for File::Path contains the following excerpt:
@created = make_path('foo/bar/baz', '/zug/zwang', {
verbose => 1,
mode => 0711,
});
Indeed, in my script(s) that syntax works fine, like this for example make_path($page,{mode=>0775})
However, when I point perlcritic at the script(s), I get warnings like the following about how leading zeros should be avoided:
Integer with leading zeros: "0775" at line 657, column 34. See page 58 of PBP. (Severity: 5)
What is the right way to resolve that warning or error? Putting it in quotes does not have the desired effects.
PS. Any tips on non-Amazon book sellers inside the EU which can sell a paper copy of PBP?
|
Benchmarking Perl's Net::Async::FastCGI app consistently return LOTS of "Non-2xx responses"
3 direct replies — Read more / Contribute
|
by Anonymous Monk
on Dec 04, 2025 at 15:04
|
|
|
Seeking community wisdom on why the ApacheBench utility consistently returns a lot of "Non-2xx responses" ( 502 Bad Gateway ) when running a benchmark test of my helloworld web app using Perl's Net::Async::FastCGI and Nginx as a reverse proxy. The number of concurrent requests is pretty low at 50, but it still return lots of "Non-2xx responses"?? Any insight is greatly appreciated. Please see below for the test code and the ApacheBench command for benchmark test:
1. ApacheBench command: Send 100 requests at concurrency level of 50:
==============================================================================
ab -l -v 2 -n 100 -c 50 "http://localhost:9510/helloworld/"<br/>
which returns:
...
Concurrency Level: 50
Time taken for tests: 0.015 seconds
Complete requests: 100
Failed requests: 0
Non-2xx responses: 85 #NOTE: all of these are "502 Bad Gateway"
...
2. Nginx config:
==============================================================================
location /helloworld/ {
proxy_buffering off ;
gzip off ;
fastcgi_pass unix:/testFolder/myPath/myUDS.sock ;
include fastcgi_params ;
}
3. helloworld test script:
==============================================================================
|
Windows, SBP, 'File::Copy::Recursive::Reduced' fails its tests due to permissions
1 direct reply — Read more / Contribute
|
by Intrepid
on Dec 01, 2025 at 22:22
|
|
|
(SBP means "Strawberry Perl")
I am not thoroughly knowledgeable about the NTFS (my Windows 11 filesystem is NTFS), but it appears there's a portability gotcha in File::Copy::Recursive::Reduced, as illustrated in the console output below:
"C:\berrybrew\instance\5.40.2_64\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
Unable to symlink C:\Users\somia\AppData\Local\Temp\_VXLTq6lRt\sym to target C:\Users\somia\AppData\Local\Temp\_VXLTq6lRt\old for testing: Operation not permitted at t/001-fcopy.t line 71.
# Looks like your test exited with 1 just after 9.
t/001-fcopy.t ....
Dubious, test returned 1 (wstat 256, 0x100)
Failed 76/85 subtests
(less 1 skipped subtest: 8 okay)
Unable to symlink at t/lib/Helper.pm line 179.
# Looks like your test exited with 1 just after 77.
t/002-dircopy.t ..
Dubious, test returned 1 (wstat 256, 0x100)
Failed 38/115 subtests
(less 1 skipped subtest: 76 okay)
Unable to symlink C:\Users\somia\AppData\Local\Temp\6cvtKrEDFd\sym to target C:\Users\somia\AppData\Local\Temp\6cvtKrEDFd\old for testing: Operation not permitted at t/003-rcopy.t line 78.
# Looks like your test exited with 1 just after 9.
t/003-rcopy.t ....
Dubious, test returned 1 (wstat 256, 0x100)
Failed 179/188 subtests
(less 1 skipped subtest: 8 okay)
I was not actually aiming to test or install File::Copy::Recursive::Reduced, but it was a dependency for Mouse.
As always, I will greatly appreciate any knowledge and insights. Thanks, good monks.
Dec 02, 2025 at 03:05 UTC
A just machine to make big decisions
Programmed by fellows (and gals) with compassion and vision
We'll be clean when their work is done
We'll be eternally free yes, and eternally young
Donald Fagen —> I.G.Y.
(Slightly modified for inclusiveness)
|
A Very Fast 64–Bit Date Algorithm
3 direct replies — Read more / Contribute
|
by mldvx4
on Nov 26, 2025 at 14:04
|
|
|
|
|
Normalizing diacritics in (regex) search
4 direct replies — Read more / Contribute
|
by LanX
on Nov 24, 2025 at 06:39
|
|
|
Hi
I have the problem to find multilingual filenames, where diacritics are inconsistently used. °
Of course I could do the normalization manually and map à á ä å ... -> a and so on.
But I suppose that
- I'm reinventing the wheel
- there is consistent unicode attribute for this.¹
- or a cpan module
I already looked at the regex modifiers but couldn't find any "diacritics independent" similar to /i
(The only remote possibility which comes to mind is a special locale doing the trick ...hmm)
Thanks in advance!
UPDATES
°) Latin alphabet only in my case!
¹) compare Based on "a" (U+0061)
|
Forcing encryption for Filesys::SmbClient or alternatives?
No replies — Read more | Post response
|
by Anonymous Monk
on Nov 24, 2025 at 04:55
|
|
|
Hi, I am currently using Filesys::SmbClient to access a text file but when using tcpdump I notice that the path etc are not encrypted. How do I force encryption?
I have set the following at: ~/.smb/smb.conf and /etc/samba/smb.conf
[global]
client min protocol = SMB3
client smb encrypt = required
When I use /usr/bin/smbclient the stuff seems to be encrypted. However safely passing passwords to smbclient appears to be trickier and more troublesome.
|
[SOLVED] Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI
8 direct replies — Read more / Contribute
|
by dissident
on Nov 21, 2025 at 10:03
|
|
|
There is a simple database.
root@localhost [project_db]> describe articles_table;
+------------------------+--------------+------+-----+---------+------
+-+
| Field | Type | Null | Key | Default | Extra
+ |
+------------------------+--------------+------+-----+---------+------
+-+
| db_art_id | bigint | YES | MUL | NULL |
+ |
I need the highest article ID in the column "db_art_id".
This works just fine from the console:
root@localhost [project_db]> SELECT MAX(db_art_id) FROM articles_table
+;
[...]
+----------------+
| MAX(db_art_id) |
+----------------+
| 1 |
+----------------+
1 row in set (0.01 sec)
root@localhost [project_db]>
However, when using DBI, the command errors out with this error info:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM articles_table' at line 1
If I put the articles table into double quotation marks, the error message is slightly different:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"articles_table"' at line 1
As said, the errors occur ONLY from DBI!
To make sure that there is no permissions problem etc, I even let DBI log on the MySQL server as root.
Any idea how to proceed when when things just look and work fine on the server console, but throw syntax errors when using DBI?
Edit:
Basically the code that fails is this:
my $my_articletable = 'articles_table';
my $p_db_art_id = 'db_art_id';
my $sqlcmd = "SELECT MAX($p_db_art_id) FROM $my_articletable;";
logit("SQLCMD: '$sqlcmd'");
my $sth = $p_dbh->prepare($sqlcmd);
$sth->execute();
As said, copypasting the resulting SQL command "SELECT MAX(db_art_id) FROM articles_table;" from the logfile into the MySQL monitor console does not give any hint what could be wrong, it just does what it is supposed to do.
|
Perl hashes and non-determinism
6 direct replies — Read more / Contribute
|
by Ratazong
on Nov 19, 2025 at 03:32
|
|
|
Dear monks,
I am participating in a coding-contest, where you have to steer a bot through an arena and collect gems.
(hidden gems (german only)). I am one of only two contestants using perl.
As part of the rules the bot must behave deterministic - two runs in the same arena need to result in the same result.
For random numbers this is ensured by setting a fixed seed in srand().
The challenge comes with hashes, which by design are unordered. Here I ensure determinism using sort on the keys.
But now I want to access the hash based on the order of a field inside:
foreach my $k sort { $hash{$a}{value} <=> $hash{$b}{value} } (keys %ha
+sh)
- and the values are not unique. This line resulted in non-determinism (and therefore my bot was excluded from tonights competition).
Is there a way to force perl to access a hash in a deterministic way? Similar to srand()? Or what is the preferred way to enforce it?
I could try something like
foreach my $k sort { $hash{$a}{value} <=> $hash{$b}{value} } (sort key
+s %hash)
but that doesn't seem to be elegant to me ...
Rata (waiting for enlightment)
|
How do I package up a Perl-TK app for macOS?
2 direct replies — Read more / Contribute
|
by perltux
on Nov 13, 2025 at 17:57
|
|
|
I have a GUI based application written by me in Perl, using Perl-Tk for the GUI. This application runs well on Linux, Windows and macOS (on macOS it requires an installed X11 server for the GUI).
In order to distribute this application to Windows users I packaged it up into an exe file using ParPacker and this works really well, no complaints from the users.
I tried using ParPacker on macOS but ran into problems with X11 and other libraries not being found as their location varies depending on the X11 server installed and depending on which packaging system is being used, there is XQuartz and there are X11 servers in Homebrew and Macports and there are even various distributions of Perl and related modules (the limited Perl included in macOS and the Perl packages from Homebrew and Macports), each using different paths and apparently also different library versions.
It seemed very much a mess to me and even after days of trying I wasn't able to find a satisfactory solution.
So has anybody successfully packaged up a Perl-Tk application for macOS and if yes how exactly did you do it, using ParPacker or some other method?
Any hints would be very helpful. TIA.
|
MAX and GROUP BY in DBIx::Class
4 direct replies — Read more / Contribute
|
by Anonymous Monk
on Nov 13, 2025 at 15:18
|
|
|
I have what should be a simple question, but I can't figure out how to do it in DBIx::Class (which I'm using elsewhere in this code, so I need it for this too).
I have a single table, that (for this purpose) contains an ID, a name, and a score (and other data not relevant for this question). I want to get the Result object for the highest score for each name. That's it. So, for the data
+----+-----------+-------+
| id | name | score |
+----+-----------+-------+
| 1 | John | 24 |
| 2 | John | 60 |
| 3 | Mary | 4 |
| 4 | John | 10 |
| 5 | Kate | 30 |
| 6 | Mary | 20 |
+---+------------+-------+
I want to get back rows 2 (John's highest score), 5 (Kate's highest (and only) score), and 6 (Mary's highest score).
That is, the SQL would be something simple like SELECT MAX(score), name FROM scores GROUP BY name; (except that I want to get the Result object, not the actual column values).
How can I accomplish this? The docs are pretty sketchy about grouping in general, and I can't find a good parallel anywhere.
|