Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Seekers of Perl Wisdom

( [id://479]=superdoc: print w/replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask.

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

Post a new question!

User Questions
How do I package up a Perl-TK app for macOS?
1 direct reply — 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
3 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.

Spreadsheet::ParseXLSX question on merged cells
2 direct replies — Read more / Contribute
by chafelix
on Nov 12, 2025 at 18:04

    I am using Spreadsheet:Parsexlsx to read an excel file. I need to say "if this is a merged cell, then...."

    I used ptkdb to see what attributes there are. So each cell has

    -Col and Row ( numbers)

    -Format with keys (AlignH,AlignV, BdrColor, BdrDiag,Bdrstyle)

    -Fill (an array)

    -FmtIdx (a number)

    -Font (another hash ref)

    -FontNo

    -Hiden

    -a number of Ignores

    -FormatNo

    -Rich

    -Sheet

    -Type

    _Val and value

    -Lock

    -Rotate

    -Shrink

    -Wrap, (all these numbers)

    The problem is none of these seem to have the info I need. Any ideas?

Update Old Selenium Tests
3 direct replies — Read more / Contribute
by hbarnard
on Nov 12, 2025 at 04:38

    I have a fairly substantial, but 'old', set of tests for Cclite. They use, or used use Test::WWW::Selenium; which now doesn't seem to find a webdriver on any version of Selenium that I download

    Error requesting http://10.0.0.65:4444/selenium-server/driver/: 404 Not Found

    My tests all take the form of

    $sel->open_ok("/cgi-bin/cclite.cgi"); $sel->type_ok("registry", 'dalston'); $sel->type_ok("userLogin", $user); $sel->type_ok("userPassword", "password"); $sel->submit("form") ;

    I'd really like to find some way to use/re-use them without too much extra work. I'm prepared to do a little Java and recompile Selenium if it comes to that

What is cpan (the installer) doing prepending all these directories to the PERL5LIB path?
2 direct replies — Read more / Contribute
by Intrepid
on Nov 11, 2025 at 14:37

    Hello folks. I am puzzled. I've been noticing a message from cpan that I don't remember seeing before; an example is below. I was seeing 17 build dirs and then I ran install for a couple more today, and it jumped to 19. Why and how is cpan doing this? I know it's necessary when a module being built/tested/installed has prerequisites but they seem to be hanging around long after they are necessary. Anyone? If you're in the know, kindly enlighten me.

    Prepending blib/arch and blib/lib of 19 build dirs to PERL5LIB, reaching size 2952; for 'install'

    perl is CygwinPerl 5.40.3
    CPAN/cpan is v2.38

    Nov 11, 2025 at 19:36 UTC

Can I (with XS) invoke the regex engine without making copies of the buffer?
1 direct reply — Read more / Contribute
by NERDVANA
on Nov 09, 2025 at 13:36
    This is related to my module Crypt::SecretBuffer, where the goal of the module is to prevent leaking secrets into the freed heap memory of the perl process where something could later come along and scan the address space looking for leftover secrets. The SecretBuffer tries to isolate data from being looked at by any normal Perl ops, so that it can be exclusively be viewed by XS/C functions and wiped clean when it goes out of scope.

    So, in that context, is there any way to use "pregexec" to apply the perl regex engine to my buffer but prevent it from making copies into perl-owned buffers? pregexec seems a bit under-documented... It says "described in perlreguts" but while that has pages upon pages of the inner workings of the regex engine, it doesn't even tell the meaning of the return value of pregexec or explain exactly what the final "nosave" parameter means. Ideally it would be a flag that does exactly what I want and avoids copying any buffers into any global variables, but that doesn't seem to be the case from looking at the C code. (which I admit I haven't taken the time to fully understand yet)

    I'd also be OK if it made copies, but someone could tell me a reliable way to go zero out the buffers of those SVs so that all the captures magically appear to be full of NUL characters afterward.

    Basically I'd like it to behave like standard C library regexec that just records positions of the capture groups in an array. I'm also debating if I should just use libc's regexes and declare that limitation on the SecretBuffer API, that you have to restrict yourself to Posix extended regex notation.

    Update:

    So actually the "nosave" parameter does appear to do some of what I want. Setting that flag prevents any of the magic variables from getting updated.

    perl -e 'use v5.40; use Inline C => q{ int call_pregexec(SV *regex, SV *sv) { REGEXP *rx= SvRX(regex); STRLEN len; char *buf= SvPV(sv, len); return pregexec(rx, buf, buf+len, buf, 0, sv, 1); } }; say "098mnb" =~ /([0-9])([a-z])/; say call_pregexec(qr/([a-z])([0-9])/, "abc123"); say $&; say $1; say $2; say $+[0]; say $+[1];'

    but then, the question becomes how to find out *where* the regex matched, since it didn't update any of the output variables.

Problem Declaring a hash
3 direct replies — Read more / Contribute
by The_Evil_One
on Nov 05, 2025 at 14:39

    I am learning Perl using a book downloaded from the internet.

    Opal is a system for charging fares on public transport in NSW Australia. I have had four Opal cards and they identified by 16 digit numbers. I have four target directories into which the files related to these cards go and I have tried to set up a hash to map between card numbers and the destination directories but it does not work and the error messages make no sense to me.

    This is the current form of the hash definition which is at line 26 in the script:-

    my %OCN_PFX_To_TDir=( 3085220111379778 => '3085220111379788_Rexx', 3085220334620644 => '3085220334620644_Spare', 3085220346432582 => '3085220346432582_Rexx2', 3085220352420034 => '3085220352420034_Algol' ); This is the input followed by the error messages I get:- carl@md-tower-004:~$ perl ~/bin/copy_opal1.plx Can't modify constant item in scalar assignment at /home/carl/bin/copy +_opal1.plx line 26, near ");" Execution of /home/carl/bin/copy_opal1.plx aborted due to compilation +errors (#1) (F) You aren't allowed to assign to the item indicated, or otherwi +se try to change it, such as with an auto-increment. Uncaught exception from user code: Can't modify constant item in scalar assignment at /home/carl/bin/ +copy_opal1.plx line 26, near ");" Execution of /home/carl/bin/copy_opal1.plx aborted due to compilat +ion errors.

    I am writing a small program to copy Opal related files from my downloads directory to the appropriate destination directories.

    Basically it tells me that I am trying to assign a scalar value to the % sign representing the modulus operator which cannot receive such a value but the % sign is to mark the variable as being a hash. I have tried various changes on the definition, originally I had both keys and values in double quotes now I have the values in single quotes, originally I used commas to separate key value pairs. No matter what I change the error messages remain the same.

    It may be that the book I downloaded is old and some syntax suggested in the book no longer works but no matter how many queries I have put into Google and how many AI overviews I have seen and hit list links that I have followed nothing has confirmed this.

Fetching 'http://search.cpan.org/uploads.rdf' (from cpan) LibXML error is triggered
3 direct replies — Read more / Contribute
by Intrepid
on Nov 05, 2025 at 13:09

    Hello Monks and Nuns. I was working with cpan (the installer) on CygPerl today and tried the command recent; it didn't work and this is what I saw:

    
    cpan2> recent
    CPAN: XML::LibXML loaded ok (v2.0210)
    Fetching 'http://search.cpan.org/uploads.rdf'
    CPAN: LWP loaded ok (v6.80)
    DONE
    
    Catching error: "XML::LibXML::Error=HASH(0xa01ebe148)" at /usr/local/share/perl5/site_perl/5.40/CPAN.pm line 397.
            CPAN::shell() called at -e line 1
    

    Could anyone else try this and see what happens? I'd appreciate it.

    My system setup is:

    This is perl 5, version 40, subversion 3 (v5.40.3) built for x86_64-cygwin-threads-multi
    /usr/lib/perl5/vendor_perl/5.40/x86_64-cygwin-threads/XML/LibXML.pm
    XML::LibXML version 2.0210
    CPAN        version 2.38
    @INC:
    /usr/local/lib/perl5/site_perl/5.40/x86_64-cygwin-threads
    /usr/local/share/perl5/site_perl/5.40
    /usr/lib/perl5/vendor_perl/5.40/x86_64-cygwin-threads
    /usr/share/perl5/vendor_perl/5.40
    /usr/lib/perl5/5.40/x86_64-cygwin-threads
    /usr/share/perl5/5.40
    
    Nov 05, 2025 at 18:08 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)

Making DBI with SQLite3 truly read-only
1 direct reply — Read more / Contribute
by mldvx4
on Nov 04, 2025 at 09:25

    Greetings, wise monks,

    I am trying to crank down restrictions on an FCGI script. I have DBI opening an SQLite3 database as read-only. This is how I am currently connecting to the database:

    my $dbh = DBI->connect("dbi:SQLite:dbname=$database", undef, undef, { AutoCommit => 0, RaiseError => 1, on_connect_do => "PRAGMA foreign_keys = ON", sqlite_open_flags => "DBD::SQLite::OPEN_READONLY", }) or die("Could not open database '$database': $!\n");

    However, AppArmor still gives the following error about needing write access, even though the error and restrictions causing it do not impair the script from appearing to work as expected:

    2025-11-04T14:02:51.130580+00:00 ID28399 kernel: [5084204.347595] audi +t: type=1400 audit(1762264971.124:63): apparmor="DENIED" operation="o +pen" profile="/var/www/fcgi/foo.fcgi" name="/var/www/db/foo.sqlite3" +pid=377569 comm="search.fcgi" requested_mask="wc" denied_mask="wc" fs +uid=1002 ouid=1002

    and in the AppArmor profile:

    /var/www/db/foo.sqlite3 kr,

    If I add w to that, the errors go away. However, I don't want to do that because the script's access is supposed to remain read-only. Yet it appears that DBI is somehow still requesting some kind of write access, even if it does not use it. What can I change in the DBI connection to ensure that it is purely read-only as far as the database goes?

Latest Strawberries: addresses reported by "p", Devel::Peek, etc.
3 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 30, 2025 at 18:59
    use strict; use Devel::Peek; $Devel::Peek::pv_limit = 3; use warnings; printf "$^V\n"; my $s = 's' x 32; Dump $s; my $addr = pack 'p', $s; printf "Q: hex: %x, dec: %1\$d\n", unpack 'Q', $addr; Dump $s; __END__ v5.32.1 SV = PV(0x1fbf48) at 0x24f0e08 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x2565cb8 "sss"...\0 CUR = 32 LEN = 34 Q: hex: 2565cb8, dec: 39214264 SV = PV(0x1fbf48) at 0x24f0e08 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x2565cb8 "sss"...\0 CUR = 32 LEN = 34 v5.42.0 SV = PV(0x1330f20f4c0) at 0x1330f2836a0 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x1330f3129f0 "sss"...\0 CUR = 32 LEN = 40 COW_REFCNT = 1 Q: hex: 1330f312400, dec: 1318809838592 SV = PV(0x1330f20f4c0) at 0x1330f2836a0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x1330f312400 "sss"...\0 CUR = 32 LEN = 34

    Previously (5.32), there was consistency as expected: PV address was "real" RAM address; and simple fact of "packing to pointer" didn't change scalar' guts. Now, I see some weird huge ("virtual"?) addresses -- even though everything works (including, not shown above, accessing (or acquiring, same values) these pointers from C). Where such numbers come from, is this the new normal? Is difference in "Dump" output related to that, or totally another issue?


Add your question
Title:
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others examining the Monastery: (5)
    As of 2025-11-14 22:58 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What's your view on AI coding assistants?





      Results (71 votes). Check out past polls.

      Notices?
      hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
      erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.