Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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
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

Strawberry Perl-5.30.3 is available
on Aug 02, 2020 at 09:02
1 reply by syphilis

    Just noticed that Strawberry Perl-5.30.3 is now available.
    The date given there is 2020-07-13, but I know it wasn't available earlier today. (Looks like the date is the date that perl was built - not the date at which the distro became available.)

    Hopefully, that indicates that 5.32.0 might not be too far away.
    Actually, I build my own perls on Windows and therefore don't rely on the Strawberry project for perl. It's still a very handy reference for me, but.
    And I do look forward to using the updated gcc compiler that usually accompanies new Strawberry Perl major releases.
    Since the mingw-w64 project stopped providing recent builds of gcc (as of a couple of years ago), I've come to rely on Strawberry for my gcc upgrades.

    Anyway ... just thought it was worth mentioning ... and looking forward to a 5.32.0 release soon, with (fingers crossed) gcc-9 or gcc-10.

all permutations of given lenght
4 direct replies — Read more / Contribute
by cataclismic_user
on Aug 11, 2020 at 03:11
    Dear Perl Monks,

    I am a novice of Perl. My question is rather simple: how can I generate all permutations of a set of characters, with a given length, in an computationally efficient manner?

    To further explain my conundrum: I have a large list of elements such as O=C(O)C(N)CCC/N=C(\N)N, O=C(N)C[C@H](N)C(=O)O, O=C(O)[C@@H](N)Cc1cncn1 and so on. I want to generate all possible permutations, including repetitions of these strings, in a given length (for ex. 6).

    Thank you in advance!

CPAN Module to determing overlap of 2 lists?
7 direct replies — Read more / Contribute
by wazat
on Aug 10, 2020 at 17:27

    I want to determine the overlap between the end of one list and the beginning of another. I have a quick brute force solution, but prefer to use an existing module if one is available. I didn't find one when I searched metacpan, but that doesn't mean it doesn't exist.

    # example @list1 = qw(a b c); @list2 = qw(b c d); # a b c # b c d # 1 2 list_overlap( \@list1, \@list2 ); # returns 2 @list1 = qw(a b c d b); @list2 = qw(b c d); # a b c d b # b c d # 1 list_overlap( \@list1, \@list2 ); # returns 1

    I don't know if this problem has a name.

    Intended use is to combine two bash_history files captured on different dates into a single bash_history file that doesn't duplicate the overlap between the files. (Yes, if I set HISTFILESIZE to -1, then bash would maintain an unlimited history file.

    __edit__ As pointed out, I should also specify that I want the largest overlap.

Not understanding while loop counting
5 direct replies — Read more / Contribute
by zapdos
on Aug 10, 2020 at 03:56
    $count = 0; while ($count < 10) { $count += 1; print "count is now $count\n"; }

    I don't get it. Why is it printing till 10 if the conditional expression asserts it should be less than (<) 10 and not less than or equal (<=) to 10? Shouldn't it print just till 9?

Generalizing a REGEX
2 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 08, 2020 at 14:55
    foreach (@newlist) { $_ =~ s/[.](.*)/($section) }

    The above code performs the transform cat.1 ---> cat(1) It also performs the transform ---> ld(5) # which is WRONG! Is there a way to generalize this regex so it does: cat.1 ---> cat(1) ---> Thanks

Dependencies for a project - Perl6/Raku
2 direct replies — Read more / Contribute
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
2 direct replies — 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
4 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...
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 about the Monastery: (1)
As of 2020-08-12 03:29 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (64 votes). Check out past polls.