Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

Donations gladly accepted

If you're new here please read PerlMonks FAQ
and Create a new user.

poll ideas quest 2020
Starts at: Jan 01, 2020 at 00:00
Ends at: Dec 31, 2020 at 23:59
Current Status: Active
10 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
Marketing and branding for The Perl Foundation (TPF) poll
on Aug 07, 2020 at 21:51
0 replies by Lady_Aleena

    I came across the Marketing and branding for The Perl Foundation (TPF) poll, and thought you all might want to participate in helping the TPF come up with a marketing plan.

    My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
German Perlmongers Online Meeting
on Aug 04, 2020 at 12:59
0 replies by LanX
    @ All German speakers here:

    Next German PM Online Meeting in (cough) 30 minutes.


    Hallo Perlmongers aus den deutschsprachigem Raum,

    Heute, am Dienstag, den 4. August 2020, um 19:30 Uhr ist German-PM Online-Treffen im Jitsi.

    Dank Corona wurde das Online-Treffen mehrfach in Erlangen und Frankfurt ausprobiert. Der Wunsch wurde geäußert, das online neben den Treffen vor Ort weiterzuführen.

    Nimm an der Besprechung teil:

    I'm not the organizer, but I'll use this thread for future announcements.


    on Daxim's request



    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Dependencies for a project - Perl6/Raku
No replies — Read more | Post response
by asoftware
on Aug 08, 2020 at 02:06

    Good day Monks,

    It has been a decade since I wrote any Perl, and recently I noticed the growth of Perl6 and the coining of "Raku". Side note, I am very pleased to see the Perl family withstanding the test of time. I recall my most productive engineering days were spent lovingly writing Perl.

    The wisdom I seek is two fold:

    1. Is there an ordained or at least idiomatic method of describing the module dependencies of a Raku project?
    2. Is there an ordained or at least idiomatic project structure for a Raku project? I see mi6, which appears to be the module structure required for module authors

    Generally, I am interested in understanding if there has been any formalization of describing required modules, not just in another module/package, but also in an arbitrary project. And potentially supporting project specific versions/installations of modules per project.

    Thanks for your time

    -- Cam
XML::LibXML::XPathContext->string_value - should ALL of the descendant's text be there?
1 direct reply — Read more / Contribute
by bobn
on Aug 07, 2020 at 22:52

    So I started playign around with XML parsing (well HTML but it's well enough formed I can use XML parsers on it). I ran into something on the Perl side of things I don't understand.

    I get a nodeset, start walking through it and getting text out, but when it comes out, for each node I get the text contained in node element AND the text of all of it's descendants (contained elements).

    I'm getting this with XML::LibXML::XPathContext, but it happens with XML::XPath as well.

    The event driven parsers I've tried don't seem to have this issue - they think that Text belongs to the innermost containing element, just like I do. lxml.etree in python, their binding for libxml2, does not do this, (though it definitely has oddities of it's own - check out "tail text" sometime, it's a doozy!).

    I'm going to stop now, 'coz I'm becoming increasingly sure I'm just missing something stupidly.

    Is it supposed to do this, and if so, how do I get at just the text for the outermost element of my node?

    #!/usr/bin/perl use XML::LibXML::XPathContext; our $contents = <<EOT; <html> <head> <title>Title_Text</title> </head> <body> <p>paragraph_text</p> <div> <div> innnermost_text </div> </div> </body> </html> EOT open my $fh, '>', './x.html'; print $fh $contents; close $fh; my $init_node = XML::LibXML->new->parse_file('./x.html'); my $xp = XML::LibXML::XPathContext->new($init_node); my $i= 0; my $nodeset = $xp->findnodes('//*'); for my $node ($nodeset->get_nodelist) { my $elname = $node->getName(); print qq[<$elname> node - $i\n]; my $text = ''; $text = $node->string_value(); # this brings in text of # *all* descendant nodes $text =~ s/(\s)+/$1/msg; print 'Text = ', $text, "\n"; $i++; }
    <html> node - 0 Text = Title_Text paragraph_text innnermost_text <head> node - 1 Text = Title_Text <title> node - 2 Text = Title_Text <body> node - 3 Text = paragraph_text innnermost_text <p> node - 4 Text = paragraph_text <div> node - 5 Text = innnermost_text <div> node - 6 Text = innnermost_text

    --Bob Niederman,

    All code given here is UNTESTED unless otherwise stated.

IO::Socket::SSL install problems
1 direct reply — Read more / Contribute
by Anonymous Monk
on Aug 07, 2020 at 19:04

    Hello smart monks, I'm trying to install IO::Socket::SSL from CPAN on a windows 10 server and it keeps on hanging. I've tried shipping the connection tests and a force install and I get to the point below where it sits for hours. Any help on how to get past this would be greatly appreciated. Terminal output is right below:

    # connect to 0: success reuse=0 version=TLSv1_3 t/session_ticket.t ................ 1/6 # connect to 0: success reuse= +1 version=TLSv1_3 # connect to 1: success reuse=1 version=TLSv1_3 # connect to 1: success reuse=0 version=TLSv1_3 # connect to 0: success reuse=0 version=TLSv1_3 # connect to 0: success reuse=1 version=TLSv1_3 t/session_ticket.t ................ ok t/sessions.t ...................... ok t/set_curves.t .................... ok t/signal-readline.t ............... skipped: signals not relevant on t +his platform t/sni.t ........................... ok t/sni_verify.t .................... 1/17


Basic but stupid problem i cannot wrap my head around
3 direct replies — Read more / Contribute
by baxy77bax
on Aug 06, 2020 at 04:57

    so the problem is the folloving:

    perl -le '$t="a/b"; if ($t =~/^(.*?)\//){$z=$1}elsif($t=~/\/(.*)/){$z= + $1} print $z' #prints a perl -le '$t="/b"; if ($t =~/^(.*?)\//){$z=$1}elsif($t=~/\/(.*)/){$z= +$1} print $z' #prints nothing
    it is probably something stupid , as i am quite tired but why isn't the second case being evaluated (or it is but why is it returning 0 )



Tk pop-up if condition is met
2 direct replies — Read more / Contribute
by IB2017
on Aug 05, 2020 at 17:18

    Is it possible to allow a popup in a text widget only if a condition is met, i.e. if a text has been selected? This is the code I have so far, which creates a popup, however, it checks if something has been selected only agter its creation.

    use strict; use warnings; use Tk; use Tk::Text; my $mw = tkinit(); my $text = $mw->Text()->pack(); $text->insert('end',"This is my first line\n"); $text->insert('end',"This is my second line\n"); PupupTextWidget($mw, $text); $mw->MainLoop(); sub PupupTextWidget{ my ($mw, $obj) = @_; my $messagePopupSave; if ($^O eq 'MSWin32'){ $messagePopupSave="Do something (ctrl+s)"; }else{ $messagePopupSave="Do something (cmd+s)"; } my $menu = $mw->Menu(-tearoff=>0, -menuitems=>[ [command=>$messagePopupSave, -command=>[sub { my $UserInput=$obj->getSelected; print $UserInput; }, $obj,]], [qw/command Copy/, -command=>['clipboardCopy', $obj,]], ]); $obj->menu($menu); return $obj; }
Looking for alternative for IPC::Shareable (or increase size)
7 direct replies — Read more / Contribute
by DomX
on Aug 05, 2020 at 16:55
    Hey Monks!
    I'm having a hard time today. I almost finished my program with over 9000 lines, but have one problem:

    Communication between my worker (forked unit) and master (GUI unit) has a size issue: (worker fills shared array, master reads content into not shared array and cleans shared array.)
    Length of shared data exceeds shared segment size at ./ line 1210.
    Buffer size is declared to be "65536". (No idea of unit, I think it's bytes.) This happens on one array element, when the containing string is longer than 65536.

    What I want to know:
    - is there a possibility to increase the size?
    - is there an alternative function, which allows me to share (bit long) text data between processes, without writing to disk? (Writing to Sqlite would decrease speed on this step extremely)

    If you don't know something like this, the only idea I have left is to make a Sqlite database "transfer", with just one column "data", and each row contains one string of my array. Many forks writing to it (slow...) and master reading and cleaning this table, just to prepare it to be saved in correct table and correct columns...
Scriptsock does not exist??
2 direct replies — Read more / Contribute
by marknher
on Aug 04, 2020 at 19:26

    Hi Monks!

    I have a perl sript ticketing system that is admittedly old but works perfect for our company. Recently, we started getting ERROR 503 messages on our website and it goes away in about 30 minutes. I reached out to the server admins and they responded with the following

    While revising this case our administrators have noticed you script is using socket connections which not completely closed and error similar to arises:

    AH02833: ScriptSock /var/run/cgid.sock.23916 does not exist:

    since the script attempts to reference to previous non existing socket previously used and the error noticed arises. We can not offer debugging of the scripts although and you should check with your website developers what socket connections are used, how are these closed and why the processes reference to an old connection so they could avoid that for your script.

    I've Googled around about this and went through my scripts trying to figure out anything that has changed but I come up blank. Anyone have any clues on what this really means so that I can hunt down the problem and fix it?

    Thanks, Mark T.

TK Listbox: scrolling with keys/mousewheel
1 direct reply — Read more / Contribute
by Ratazong
on Aug 04, 2020 at 03:57

    Dear monks

    I'm struggeling with creating a scrolled listbox in Tk: the code below works, however I'm not able to scroll with the arrow-keys nor with the mouse-wheel. Do I have to bind the events myself and code the related actions? Or am I just missing something?

    Thanks for your help! rata

    sub selectProjectDialog_newtest { $mw = shift; # store the main window my @project_choices = split(" ","Project1 Project2 Project3 Proje +ct4 Project11 Project12 Project13 Project14 ") ; my $projectSelection_tl= $mw->Toplevel( ); $projectSelection_tl->title("Select the project:"); $projectSelection_tl->Label(-text => 'Select the project Id:', + )->grid(-row => 5, -column => 10, -sticky => "w"); my $scrolled1 = $projectSelection_tl->Scrolled ("Listbox", -scrollbars => "se", -width => 50, -height => 4, -selectmode => "extended") ->grid(-row => 10, -column => 10, -columns +pan => 10, -rowspan => 10); $scrolled1->insert ("end", @project_choices); }

Effect of redirecting output to /dev/null on $? value
2 direct replies — Read more / Contribute
by Special_K
on Aug 02, 2020 at 20:14

    For reference, this is somewhat of a follow up question to a question I asked previously:

    What is the impact on the value of $? if the output of an application is redirected to /dev/null? This is running under RHEL7.

    For example, suppose I have a perl script that calls a compiled executable that seg faults:

    `my_executable_that_seg_faults`; my $exit_value = $? >> 8; my $signal_num = $? & 127; my $dumped_core = $? & 128; printf("return value is %d\n", $?); printf("exit_value = $exit_value\n"); printf("signal_num = $signal_num\n"); printf("dumped_core = $dumped_core\n");

    Running the above code produces the following output:

    return value is 11 exit_value = 0 signal_num = 11 dumped_core = 0

    This output is consistent with what I would expect based on information found here related to the $? variable:

    However if I change the executable call above to the following:

    `my_executable_that_seg_faults > /dev/null`;

    The following output is produced:

    return value is 35584 exit_value = 139 signal_num = 0 dumped_core = 0

    The above output is significantly different even though the application still seg faulted. Here are my questions:

    1. Why did the value of $? completely change when I added the output redirect to /dev/null but kept everything else the same?

    2. Does the value of $? in the second case still contain the same information but encoded differently?

    I created a different application with an intentional segmentation fault and called it using the above perl script. It produced the exact same output, suggesting that this behavior is not dependent on the behavior of the called application.

PerlMonks Discussions
Preview neither truncates nor warns
2 direct replies — Read more / Contribute
by hippo
on Aug 05, 2020 at 04:38

    Reading Re^10: XS.c: loadable library and perl binaries are mismatched (got handshake key 0xc100000, needed 0xc180000) I was encouraged to confirm what rgren925 reported. I constructed a reply with about 120kB in it and used the Preview button to check it. All of it was rendered and there was no warning (that I could see) that it was over the size limit for posting. When it was subsequently submitted it still rendered fine and it was only on a further navigation to the same node that it did truncate to ~64kB as I expected.

    This is not great from a UX perspective. The preview should either warn about the size or truncate it like the final submission would do or (ideally IMHO) both. The full text could still be retained in the textarea for ease of editing.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-08-08 09:24 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (51 votes). Check out past polls.