CINXE.COM
PerlMonks - The Monastery Gates
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- Took this out for IE6ites "http://www.w3.org/TR/REC-html40/loose.dtd" --> <html lang="en"> <head id="stdcontainer"> <title> PerlMonks - The Monastery Gates </title> <link rel="canonical" href="https://www.perlmonks.org/?node_id=131" /> <!-- Theme : Web safe blue PerlMonks Theme --> <script language="javascript" type="text/javascript" src="?node=list%20replies%20toggle%20javascript" integrity="sha384-6jdBZxT7udN82vOTryPaLwqMohSfDF3HXv3M32KAZ7dOREMdAkYh9ZhoaKCgCXcr" crossorigin="anonymous"></script> <link rel="stylesheet" href="/css/common.css" type="text/css" /> <link rel="stylesheet" href="?node_id=204962" type="text/css" /> <!-- No CSS Link in Display Settings --> <!-- No CSS Data in Display Settings --> <link rel="icon" href="/favicon.ico" /> <meta name = "description" content = "A community committed to sharing Perl knowledge and coding tips. The site contains questions and answers, useful snippets, and a library of code." /> <meta name = "keywords" content = "perl, mod_perl, regular expressions, regexp, CGI, programming, learning, tutorials, questions, answers, examples, node, experience, votes, code" /> </head> <body id="id-131"> <!-- monktainer --> <!-- monkbar2001 --> <table id="monkbar" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr class="bannerrow"> <td align="left" width="100%"> <a href="http://pair.com"> <img src="//promote.pair.com/i/pair-banner-current.gif" height = "60" width = "468" alt = "Beefy Boxes and Bandwidth Generously Provided by pair Networks" /> </a> </td> <td rowspan="2" align="right" valign="bottom"> <!-- Monk Pic Turned Off In User Settings --> </td> </tr> <tr class="monkquip"> <td class="monkquip" valign="bottom" width="100%" > Just another Perl shrine </td> </tr> <tr class="titlebar"> <td class="titlebar"> <form method="get" action="?" enctype="application/x-www-form-urlencoded" > <input type="text" name="node" id="search_text" size="20" maxlength="300" /> <input class="titlebar" type="submit" value="Search" /> </form> </td> <td class="titlebar" id="mb2001titlebar" align="right" > <a class="titlebar" href="?">PerlMonks</a> </td> </tr> </table> <!-- /monkbar2001 --> <!-- Begin title bar --> <table width="98%" align="center" id="titlebar-top"> <tbody> <tr> <td valign="middle" class="titlechooser"> <!-- node_info_string: (h3)Title and (span)Author --> <h3 class="superdoc">The Monastery Gates</h3> <!-- /node_info_string --> </td> <td valign="top" align="right" class="monktitlebar"> <!-- monktitlebar --> <ul class="topnavmenu inline-list"> <li><a href="?node_id=109">Log in</a></li><li><a href="?node_id=101">Create a new user</a></li> <li><a href="?">The Monastery Gates</a></li> <li><a href="?node=Seekers%20of%20Perl%20Wisdom">Seekers of Perl Wisdom</a></li> <li><a href="?node=Meditations">Meditations</a></li> <li><a href="?node=Cool%20Uses%20for%20Perl">Cool Uses For Perl</a></li> <li><a href="?node=Obfuscated%20Code">Obfuscation</a></li> <li><a href="?node=Tutorials">Tutorials</a></li> <li><a href="?node=Perl%20Poetry">Poetry</a></li> <li><a href="?node=Illuminations">Illuminations</a></li> <li><a href="?node=Reviews">Reviews</a></li> <li><a href="?node=Perl%20News">Perl News</a></li> <li><a href="?node=Recently%20Active%20Threads">Recent Threads</a></li> <li><a href="?node=Newest%20Nodes">Newest Nodes</a></li> <li><a href="?node=Super%20Search">Super Search</a></li> <li><a href="?node=Perl%20Monks%20Discussion">PerlMonks Discussion</a></li> <li><a href="?node=Tidings">What's New</a></li> </ul> <!-- args=(monktitlebar sitedoclet -TOPNAV_SPECIAL <li><a href="?node_id=109">Log in</a></li><li><a href="?node_id=101">Create a new user</a></li>) NODE.title = The Monastery Gates NODE.owner = 485628 N.title = monktitlebar sitedoclet N.owner = 17342 --> <!-- /monktitlebar --> </td> </tr> </tbody> </table> <table width="98%" align="center" id="titlebar-bottom"> <tbody> <tr> <td valign="middle" class="titlechooser"> <!-- node_info_string: (span)Date and (span)Links --> <span class="addlinks">( <a href="?node_id=131">[id://131]</a>=<a href="?node_id=14">superdoc</a>: <a rel="nofollow" href="?node_id=131;displaytype=print">print</a> <a rel="nofollow" href="?displaytype=print;replies=1;node_id=131">w/replies</a>, <a href="?displaytype=xml;node_id=131">xml</a> )</span> <!-- /node_info_string --> </td> <td valign="middle" align="right" class="monktitlebar"> <a href="?node=PerlMonks%20FAQ">Need Help??</a> </td> </tr> </tbody> </table> <!-- End title bar --> <!-- Begin main (monktainer) --> <center> <table width="98%"> <tr> <td width="80%" valign="top" class="main_content"> <!--contained stuff--> <!-- BEGIN general container --> <p align='center'><i>New here?</i> ⇒ <a href="?node_id=17974">I want to ask a question of the Perl Monks. Where do I start?</a></p> <div class="link-back"><b><a href="?node=Offering%20Plate">Donations gladly accepted</a></b></div> <!-- <a href="https://plus.google.com/110429821816504715800" rel="publisher">Google+</a> --> <!-- args=() NODE.title = The Monastery Gates NODE.owner = 485628 N.title = The Monastery Gates sitedoclet N.owner = 17342 --> <blockquote> <h4>Notices:</h4> <table> <tr><th></th><td>• <i><a class="hoverDate" href="?node_id=1131330" title="2025-03-24 08:23:38">erzuuli</a></i></td><!-- <td>[id://651530]</td> --><td>‥ <a href="?node=Anonymous%20Monk">Anonymous Monk</a>s are no longer allowed to use Super Search, due to an excessive use of this resource by robots.</td></tr> </table> </blockquote> <p style="text-align:center">If you're new here, please read <a href="?node=PerlMonks%20FAQ">PerlMonks FAQ</a><br /> and <a href="?node=Create%20a%20new%20user">Create a new user</a>!</p><table width="100%" cellpadding="0" cellspacing="0"> <tr class="section_title" width="100%" border="1"> <td class="section_title" width="100%"> Quests </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <tr width="100%" class="highlight"><td> <a href="?node_id=11163477">poll ideas quest 2025</a><br /> Starts at: Jan 01, 2025 at 00:00<br /> Ends at: Dec 31, 2025 at 23:59<br /> Current Status: Active </td> <td valign="top"> <a href="?node_id=11163477">3 replies</a> </td> <td valign="top"> by <a href="?node_id=275323">pollsters</a> </td> </tr> <tr><td> <ul>First, read <a href="?node=How%20do%20I%20create%20a%20Poll%3F">How do I create a Poll?</a>. Then suggest your poll here. Complete ideas are more likely to be used. <p> Note that links may be used in choices but not in the title.</ul> </td></tr> </table> </td> </tr> </table> <!-- BEGIN listapproved default outer container --> <table width="100%" cellpadding="0" cellspacing="0"> <tr class="section_title" width="100%" border="1"> <td class="section_title" width="100%"> Perl News </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <!-- BEGIN embed node container --> <TR class="highlight"><TD><a href="?node_id=11164086">CPANSec is now CNA!</a> <BR> on Feb 26, 2025 at 04:05 </TD> <TD valign=top> <a href="?node_id=11164086">0 replies</a> </TD> <TD valign=top> by <a href="?node_id=200365">Tux</a> </TD> </TR> <TR><TD> <ul><p>Years ago, a few people decided during the Perl Toolchain Summit (PTS) that it would be a good idea to join forces, ideas and knowledge and start a group to monitor vulnerabilities in the complete perl ecosystem form core to the smallest CPAN release. The goal was to follow legislation and CVE reports, and help authors in taking actions on not being vulnerable anymore.</p> <p>That group has grown stable over the past years and is now known as <a href="https://security.metacpan.org">CPANSec</a></p> <p>The group has several focus areas, and one of them is channeling CVE vulnerability issues.</p> <p>In that specific goal, a milestone has been reached:</p> <p><a href="https://security.metacpan.org/2025/02/25/cpansec-is-cna-for-perl-and-cpan.html">CPANSec has just been authorized as a CVE Numbering Authority (CNA) for Perl and modules on CPAN</a> 📣🎉🥳👌</p> <hr /> <p>The CPAN Security Group was <a href="https://www.cve.org/Media/News/item/news/2025/02/25/CPAN-Security-Group-Added-as-CNA">authorized by the CVE Program</a> as a CVE Numbering Authority (CNA) on Feb 25, 2025. A CNA assigns and manages CVE identifiers for projects in their scope.</p> <p>Our scope is vulnerabilities in Perl and CPAN Modules (including End-of-Life Perl versions) found at <a href="https://perl.org/">perl.org</a>, <a href="https://cpan.org/">cpan.org</a> or <a href="https://metacpan.org/">metacpan.org</a>, excluding distributions of Perl or CPAN Modules maintained by third-party redistributors.</p> <p>CVE is an international, community-based effort to identify, define and catalog publicly disclosed software vulnerabilities. To learn more about the CVE program, visit <a href="https://www.cve.org">www.cve.org</a>.</p> <h2>Report Vulnerability</h2> <p>Vulnerabilities should be reported according to the security policy of the affected project.</p> <p>For more details, see our guide on how to <a href="https://security.metacpan.org/docs/report.html">Report a Security Issue</a> in Perl and the CPAN ecosystem.</p> <h2>Contact Us</h2> <p>To request a CVE identifier, or to update a CVE we have issued, please send an email to <a href="mailto:cve-request@security.metacpan.org">cve-request@security.metacpan.org</a>.</p> <p>Subscribe to the <a href="https://lists.security.metacpan.org/cve-announce/">cve-announce mailing list</a> to be notified of new CVEs published by us.</p> <p>For questions, disputes or other CNA related queries please use <a href="mailto:cna@security.metacpan.org">cna@security.metacpan.org</a>. Disputes are handled according to the <a href="https://www.cve.org/ResourcesSupport/AllResources/CNARules">CNA rules</a>.</p> <h2>Links</h2> <ul> <li><a href="https://www.cve.org/Media/News/item/news/2025/02/25/CPAN-Security-Group-Added-as-CNA">CVE.org: CPAN Security Group added as CVE Numbering Authority (CNA)</a></li> <li><a href="https://www.cve.org/PartnerInformation/ListofPartners/partner/CPANSec">CVE.org: Partner Information - CPAN Security Group</a></li> <li><a href="https://www.cve.org/ResourcesSupport/AllResources/CNARules">CVE.org: CVE Numbering Authority (CNA) Operational Rules</a></li> <li><a href="https://security.metacpan.org/docs/report.html">Report Security Issue</a></li> <li><a href="https://lists.security.metacpan.org/cve-announce/">cve-announce mailing list</a></li> <li><a href="https://security.metacpan.org/docs/cna-disclosure-policy.html">CNA Disclosure Policy</a></li> </ul> <!-- Node text goes above. Div tags should contain sig only --> <div class="pmsig"><div class="pmsig-200365"> <br /> Enjoy, Have FUN! H.Merijn </div></div></ul> </TD></TR> <!-- END embed node container --> <!-- BEGIN embed node container --> <TR class="highlight"><TD><a href="?node_id=11164084">PDL::Stats 0.854 released</a> <BR> on Feb 25, 2025 at 14:11 </TD> <TD valign=top> <a href="?node_id=11164084">0 replies</a> </TD> <TD valign=top> by <a href="?node_id=1068773">etj</a> </TD> </TR> <TR><TD> <ul>Significant changes in recent times: <ul> <li><a href="https://rt.cpan.org/Ticket/Display.html?id=97925">https://rt.cpan.org/Ticket/Display.html?id=97925</a> has been fixed: now anova_rptd works with mixed-model designs <li>There's now a demo at <a href="https://pdl.perl.org/?page=demos/stats">https://pdl.perl.org/?page=demos/stats</a> <li>The plotting functions now use <a href="https://metacpan.org/pod/PDL%3A%3AGraphics%3A%3ASimple">PDL::Graphics::Simple</a> (which facilitates generating the above) <li>The plotting functions have also had a tidy-up, and now include plotting categorical anova data with stripcharts <li>It uses the new PDL 2.096+ "lib/*.pd" format so it builds quicker </ul> Any problems, please let us know by opening a GitHub issue, joining the IRC channel (both linked on the <a href="https://metacpan.org/pod/PDL%3A%3AStats">PDL::Stats</a> page) or emailing the pdl-general list.</ul> </TD></TR> <!-- END embed node container --> </table> </td> </tr> </table> <!-- END listapproved default outer container --> <table width="100%" cellpadding="0" cellspacing="0"> <tr class="section_title" width="100%" border="1"> <td class="section_title" width="100%"> Supplications </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <!-- 1 reply --> <!-- Begin Post --> <!-- embed node with vote container --> <tr class="post-head post_head"> <td valign="top" style="padding-left:.2em"> <!-- TITLE --> <a id ="post-head-id11164525" name="post-head-id11164525" href="?node_id=11164525" >HTTP::Cookies -> CookieJar</a> <br/> <!-- REPLIES --> 1 direct reply — <a href="?node_id=11164525">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=961">Anonymous Monk</a> <br/> <!-- DATE --> on Mar 31, 2025 at 05:49 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> <!-- anonymonk cant vote --> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul>The use of <a href="https://metacpan.org/pod/HTTP%3A%3ACookieJar">HTTP::CookieJar</a> is recommended over <a href="https://metacpan.org/pod/HTTP%3A%3ACookies">HTTP::Cookies</a>, and the core module <a href="https://metacpan.org/pod/HTTP%3A%3ATiny">HTTP::Tiny</a> only supports the former. There exists <a href="https://metacpan.org/pod/HTTP%3A%3ACookieJar%3A%3ALWP">HTTP::CookieJar::LWP</a> to allow using a <tt class='inlinecode'>HTTP::CookieJar</tt> with <a href="https://metacpan.org/pod/LWP%3A%3AUserAgent">LWP::UserAgent</a>, but I can't find anything going the other way- I want to use <a href="https://metacpan.org/pod/HTTP%3A%3ACookies%3A%3AMozilla">HTTP::Cookies::Mozilla</a> with <tt class='inlinecode'>HTTP::Tiny</tt>. In fact, all the modules to read specific browser cookies use the <tt class='inlinecode'>HTTP::Cookies</tt> interface. The following seems to work, but I expected to find some minimal documentation or implementation: <pre class="code"><div class='codeblock'><tt class='codetext'>use HTTP::Tiny; use HTTP::CookieJar; use HTTP::Cookies::Mozilla; my $cookies = HTTP::Cookies::Mozilla->new(file => $firefox_cookies_sql<span class="line-breaker"> <font color="red">+</font></span>ite_file); my @cookies = map { s/^Set-Cookie3:\s*//; $_ } split "\n", $cookies->as_string; my $cookie_jar = HTTP::CookieJar->new; $cookie_jar->load_cookies(@cookies); my $ua = HTTP::Tiny->new(cookie_jar => $cookie_jar); </tt></div><div class='embed-code-dl'><a href="?part=4;abspart=1;displaytype=displaycode;node_id=11164525">[download]</a></div></pre> </ul> </td> </tr> <!-- End Post --> <!-- 2 replies --> <!-- Begin Post --> <!-- embed node with vote container --> <tr class="post-head post_head"> <td valign="top" style="padding-left:.2em"> <!-- TITLE --> <a id ="post-head-id11164519" name="post-head-id11164519" href="?node_id=11164519" >Alternations and anchors</a> <br/> <!-- REPLIES --> 2 direct replies — <a href="?node_id=11164519">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=823433">Chuma</a> <br/> <!-- DATE --> on Mar 30, 2025 at 17:25 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> <!-- anonymonk cant vote --> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>Dear monks,</p> <p>I'm trying to search for several regexes in some long files. To speed things up, I tried first checking a combined regex, to see if any of them matches the line. Like so:</p> <pre class="code"><div class='codeblock'><tt class='codetext'>my $comb=join('|',@ARGV); while($line=<$infile>){ if($line=~$comb){ for $target(@ARGV){ if($line=~$target){ # do a thing }}}} </tt></div><div class='embed-code-dl'><a href="?part=1;abspart=1;displaytype=displaycode;node_id=11164519">[download]</a></div></pre> <p>This seems to speed things up, at least when the regexes are just plain words. But: If I try input regexes which are anchored ("^word"), then suddenly it's much slower! Is there some weirdness with alternations and anchors? Or did I make some obvious mistake?</p> <p>(I could rewrite <tt class='inlinecode'>^aaa|^bbb|^ccc</tt> as <tt class='inlinecode'>^(aaa|bbb|ccc)</tt>, but it might be that only some of the inputs are anchored.)</p></ul> </td> </tr> <!-- End Post --> <!-- 1 reply --> <!-- Begin Post --> <!-- embed node with vote container --> <tr class="post-head post_head"> <td valign="top" style="padding-left:.2em"> <!-- TITLE --> <a id ="post-head-id11164507" name="post-head-id11164507" href="?node_id=11164507" >Double-clicking a HList Entry</a> <br/> <!-- REPLIES --> 1 direct reply — <a href="?node_id=11164507">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=11164505">andy4321</a> <br/> <!-- DATE --> on Mar 30, 2025 at 03:13 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> <!-- anonymonk cant vote --> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p> The code below is the smallest example I could come up with. </p> <p>There are two curiosities that I'd like to figure-out.</p> <ol> <li>When I double-click (left-mouse-button), a small dashed box appears around the entry that's been clicked</li> <li>When I double-click (left-mouse-button), the entry changes color from green to black (still with Courier 12 bold)</li> </ol> <p>When I single (left-click) the window not containing an entry, then the entry that was clicked returns to being displayed as DarkGreen with no highlight box round it.</p> <p>Questions (somewhat inter-related):</p> <ol> <li> Is it possible to disable <tt>HList</tt> from responding to the double-left-click (so that the entry doesn't get a dashed-box and the color of the entry doesn't change)?</li> <li> On other GUIs I've written, the dashed-box has proved annoying. Is it possible to prevent the dashed-box from appearing?</li> </ol> <p>Thank you for your time. </p> <pre class="code"><div class='codeblock'><tt class='codetext'>#!/usr/bin/perl use Tk; use Tk::HList; use Tk::ItemStyle; use File::Basename; $FONT_BOLD = "Courier 12 bold"; $mw = MainWindow->new(-title => $0); $hlist = $mw->HList(-selectmode=>"none", -selectbackground=>"Wheat", -selectborderwidth=>0, -background=>"Wheat", -selectbackground=>"Wheat", -separator=>"/", -drawbranch=>1, -indicator=>1, ) -> pack(qw/-fill both -expand yes/); $Highlight = $mw->ItemStyle('text', -foreground=>"DarkGreen", -backgro<span class="line-breaker"> <font color="red">+</font></span>und=>"Wheat", -font=>$FONT_BOLD); foreach $path("/", "/home", "/home/andrew") { $hlist -> add($path, -text=>basename($path), -style=>$Highlight); } MainLoop(); </tt></div><div class='embed-code-dl'><a href="?displaytype=displaycode;node_id=11164507;part=1;abspart=1">[download]</a></div></pre> </ul> </td> </tr> <!-- End Post --> <!-- 1 reply --> <!-- Begin Post --> <!-- embed node with vote container --> <tr class="post-head post_head"> <td valign="top" style="padding-left:.2em"> <!-- TITLE --> <a id ="post-head-id11164483" name="post-head-id11164483" href="?node_id=11164483" >Tk module usage of after method</a> <br/> <!-- REPLIES --> 1 direct reply — <a href="?node_id=11164483">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=11160317">jmClifford</a> <br/> <!-- DATE --> on Mar 29, 2025 at 02:39 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> <!-- anonymonk cant vote --> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>Hi. I am using a sub with my Tk module similar to; </p> <tt class='inlinecode'></tt> <pre class="code"><div class='codeblock'><tt class='codetext'>sub tick { # Run every 1000 milliseconds. if ($toggle_scan_v eq 0) {return}; # Break out of this tick l<span class="line-breaker"> <font color="red">+</font></span>oop # Do something $kount++; print "$kount "; $mw->after(1000, \&tick); # Suggest loop here print "No Error; we should get here often. \n"; } </tt></div><div class='embed-code-dl'><a href="?node_id=11164483;displaytype=displaycode;abspart=1;part=2">[download]</a></div></pre> <p>I trust that whenever the "after" is executed, the print is executed, after which a graceful exit of the subroutine occurs. This provides dead time for the thread of execution. In turn other events belonging to this same thread may occur and execute (possibly turning $toggle_scan_v on and stopping this "tick" loop which is earmarked to execute 1000 mSec after the "after" method). </p> <p>I trust that the subroutine is called and always subsequently returns in such a manner that there is no stack littering.? </p> <p>Regards JC.... </p> </ul> </td> </tr> <!-- End Post --> <!-- 2 replies --> <!-- Begin Post --> <!-- embed node with vote container --> <tr class="post-head post_head"> <td valign="top" style="padding-left:.2em"> <!-- TITLE --> <a id ="post-head-id11164473" name="post-head-id11164473" href="?node_id=11164473" >Memory Leak with XS but not pure C</a> <br/> <!-- REPLIES --> 2 direct replies — <a href="?node_id=11164473">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=11164471">FrankFooty</a> <br/> <!-- DATE --> on Mar 28, 2025 at 12:12 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> <!-- anonymonk cant vote --> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul>Oh perl monks, <p> I'm using the 'libunistring' library in C to uppercase utf8-encoded characters. </p> <p>In C it works fine with no memory leaks according to Valgrind. But, when I try to do it in XS it works, but valgrind complains loudly.</p> <p>Here's the C: </p> <pre class="code"><div class='codeblock'><tt class='codetext'>#include <stdio.h> #include <unicase.h> #include <stdlib.h> #include <unistr.h> #include <uninorm.h> #include <string.h> #include <unistr.h> #include <unitypes.h> void main(){ char* instring = "Hauptstra遝 3"; // Works with uint8_t too size_t length; uint8_t *result; size_t input_length; input_length=strlen(instring); //u8_strlen works too result = u8_toupper (instring, input_length, NULL, UNINORM_NFC, NULL, <span class="line-breaker"> <font color="red">+</font></span>&length); </tt></div><div class='embed-code-dl'><a href="?node_id=11164473;displaytype=displaycode;abspart=1;part=1">[download]</a></div></pre> <p> The result is as expected: HAUPTSTRASSE 3</p> <p> my XS function (same includes as above):</p> <pre class="code"><div class='codeblock'><tt class='codetext'>SV* uppercase_utf8_2(SV* sv) PREINIT: size_t len; char* s; char* upperstring; //uint8_t also SV* aresult; size_t upperlength; CODE: s = SvPVbyte(sv, len); //strings from my editor (locale?) are alr<span class="line-breaker"> <font color="red">+</font></span>eady utf8 encoded upperstring = u8_toupper (s, len, NULL, NULL,NULL, &upperlength); upperlength = u8_strlen(upperstring); aresult = newSVpv(upperstring,upperlength); free(upperstring); RETVAL = aresult; OUTPUT: RETVAL </tt></div><div class='embed-code-dl'><a href="?displaytype=displaycode;node_id=11164473;part=2;abspart=1">[download]</a></div></pre> <p> All hunky-dory except for a tonne of errors from Valgirind, none of which mention the XS sub</p> <p>e.g:</p> <pre class="code"><div class='codeblock'><tt class='codetext'>==614897== Invalid read of size 1 ==614897== at 0x484F234: strlen (in /usr/libexec/valgrind/vgpreload<span class="line-breaker"> <font color="red">+</font></span>_memcheck-amd64-linux.so) ==614897== by 0x485B74A: XS_Simple__Ngram_uppercase_utf8_2 (Ngram.x<span class="line-breaker"> <font color="red">+</font></span>s:79) ==614897== by 0x2441A9: ??? (in /usr/bin/perl) ==614897== by 0x2396DD: Perl_runops_standard (in /usr/bin/perl) ==614897== by 0x1781DA: perl_run (in /usr/bin/perl) ==614897== by 0x14D639: main (in /usr/bin/perl) ==614897== Address 0x5bb9282 is 0 bytes after a block of size 18 allo<span class="line-breaker"> <font color="red">+</font></span>c'd ==614897== at 0x484DB80: realloc (in /usr/libexec/valgrind/vgpreloa<span class="line-breaker"> <font color="red">+</font></span>d_memcheck-amd64-linux.so) ==614897== by 0x55AEF01: libunistring_u8_casemap (in /usr/lib/x86_6<span class="line-breaker"> <font color="red">+</font></span>4-linux-gnu/libunistring.so.5.0.0) ==614897== by 0x55AF478: u8_toupper (in /usr/lib/x86_64-linux-gnu/l<span class="line-breaker"> <font color="red">+</font></span>ibunistring.so.5.0.0) ==614897== by 0x485B73F: XS_Simple__Ngram_uppercase_utf8_2 (Ngram.x<span class="line-breaker"> <font color="red">+</font></span>s:78) ==614897== by 0x2441A9: ??? (in /usr/bin/perl) ==614897== by 0x2396DD: Perl_runops_standard (in /usr/bin/perl) ==614897== by 0x1781DA: perl_run (in /usr/bin/perl) ==614897== by 0x14D639: main (in /usr/bin/perl) ==614897== ==614897== ==614897== HEAP SUMMARY: ==614897== in use at exit: 2,544,437 bytes in 9,481 blocks ==614897== total heap usage: 33,789 allocs, 24,308 frees, 6,454,177 <span class="line-breaker"> <font color="red">+</font></span>bytes allocated ==614897== ==614897== 2 bytes in 1 blocks are possibly lost in loss record 1 of 1<span class="line-breaker"> <font color="red">+</font></span>,342 ==614897== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload<span class="line-breaker"> <font color="red">+</font></span>_memcheck-amd64-linux.so) ==614897== by 0x24EADB: Perl_sv_magicext (in /usr/bin/perl) ==614897== by 0x24ED0A: Perl_sv_magic (in /usr/bin/perl) ==614897== by 0x183F8C: Perl_gv_fetchpvn_flags (in /usr/bin/perl) ==614897== by 0x174ED2: perl_parse (in /usr/bin/perl) ==614897== by 0x14D55B: main (in /usr/bin/perl) </tt></div><div class='embed-code-dl'><a href="?part=3;abspart=1;displaytype=displaycode;node_id=11164473">[download]</a></div></pre> <p> Any ideas? </p></ul> </td> </tr> <!-- End Post --> </table> </td> </tr> </table> <!-- END general container --> <!--/contained stuff--> </td> <!--nodelet handling code (monktainer)--> <td width="20%" valign="top" align="right" class="nodelets"> <!-- Begin nodelets --> <table class='nodelet_container' id='nodelet_container'> <!-- Nodelet Break --> <tbody class="nodelet" id="Log_In"> <tr><th class="nodelet_head"> <span class="title">Log In</span><a href="?node=About The Log In Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <form method="post" action="?" enctype="multipart/form-data" name="login"> <span><input type="hidden" name="node_id" value="109" ></input></span> <input type="hidden" name="op" value="login" /> <input type="hidden" name="lastnode_id" value="131" /> <table border="0"><tr><td> Username:</td><td> <input type="text" name="user" size="10" maxlength="34" /> </td></tr><tr><td> Password:</td><td> <input type="password" name="passwd" size="10" maxlength="10" /> </td></tr></table> <label><input type="checkbox" name="expires" value="+10y" />remember me</label> <input type="submit" name="login" value="Login" /> <br /> <a href="?node_id=2513">What's my password?</a> <br /> <a href="?node_id=101">Create A New User</a> </form> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Domain_Nodelet"> <tr><th class="nodelet_head"> <span class="title">Domain Nodelet</span><a href="?node=About The Domain Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <p class='domain_link' align='center'><a class='wwwdomainlink' href="http://www.perlmonks.com/index.pl?node_id=131">www</a>.<a class='domainlink' href="http://perlmonks.com/index.pl?node_id=131">com</a> | <a class='wwwdomainlink' href="http://www.perlmonks.net/index.pl?node_id=131">www</a>.<a class='domainlink' href="http://perlmonks.net/index.pl?node_id=131">net</a> | <a class='wwwdomainlink' href="http://www.perlmonks.org/index.pl?node_id=131">www</a>.<span class='currentdomain'>org</span></p> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Chatterbox"> <tr><th class="nodelet_head"> <span class="title">Chatterbox</span><a href="?node=About The Chatterbox Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <form method="get" action="?" enctype="multipart/form-data"> <span><input type="hidden" name="node_id" value="131" ></input></span><i>and the web crawler heard nothing...</i> <input type="submit" name="foo" value="Refresh" /> </form> <i><br /> <a href="?node=ChatterBox%20FAQ">How do I use this?</a> • <a href="?node=last%20hour%20of%20cb">Last hour</a> • <a href="?node_id=20842">Other CB clients</a></i> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Other_Users"> <tr><th class="nodelet_head"> <span class="title">Other Users</span><a href="?node=About The Other Users Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <span class="other-users-text">Others <span class="other-users-blurb">taking refuge in</span> the Monastery:</span> (3)<br /><ul class="spacey-list"><li><span class='even-row'><span class='item-000'><span class='user-level-22'><span class='user-140424'><a href="?node_id=140424" title="roho's home node. Level 22">roho</a></span></span></span></span></li> <li><span class='odd-row'><span class='item-001'><span class='user-level-20'><span class='user-200365'><a title="Tux's home node. Level 20" href="?node_id=200365">Tux</a></span></span></span></span></li> <li><span class='even-row'><span class='item-002'><span class='user-level-1'><span class='user-11155664'><a href="?node_id=11155664" title="chatterbot's home node. Level 1">chatterbot</a></span></span></span></span></li> </ul><span class='update-time'><small>As of 2025-04-03 05:05 GMT</small></span> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Sections"> <tr><th class="nodelet_head"> <span class="title">Sections</span><a href="?node=About The Sections Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <ul class="spacey-list"> <li><a href="?node=Seekers%20of%20Perl%20Wisdom">Seekers of Perl Wisdom</a></li> <li><a href="?node=Cool%20Uses%20for%20Perl">Cool Uses for Perl</a></li> <li><a href="?node=Meditations">Meditations</a></li> <li><a href="?node=Perl%20Monks%20Discussion">PerlMonks Discussion</a></li> <li><a href="?node=Categorized%20Questions%20and%20Answers">Categorized Q&A</a></li> <li><a href="?node=Tutorials">Tutorials</a></li> <li><a href="?node=Obfuscated%20Code">Obfuscated Code</a></li> <li><a href="?node=Perl%20Poetry">Perl Poetry</a></li> <li><a href="?node=Perl%20News">Perl News</a></li> <li><a href="?node_id=483086">about</a></li> </ul> <!-- args=(Sections) NODE.title = The Monastery Gates NODE.owner = 485628 N.title = Sections sitedoclet N.owner = 17342 --> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Information"> <tr><th class="nodelet_head"> <span class="title">Information</span><a href="?node=About The Information Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <ul class="spacey-list"> <li><a href="?node=PerlMonks%20FAQ">PerlMonks FAQ</a></li> <li><a href="?node=the%20Perl%20Monks%20guide%20to%20the%20Monastery">Guide to the Monastery</a></li> <li><a href="?node=Tidings">What's New at PerlMonks</a></li> <li><a href="?node=Voting%2FExperience%20System">Voting/Experience System</a></li> <li><a href="?node=Tutorials">Tutorials</a></li> <li><a href="?node=Reviews">Reviews</a></li> <li><a href="?node=Library">Library</a></li> <li><a href="?node=perlman%3Aperlfaq">Perl FAQs</a></li> <li><a href="?node=Where%20can%20I%20find%20more%20information%20on...">Other Info Sources</a></li> </ul> <!-- args=(Information sitedoclet -TIDINGS_NEW ) NODE.title = The Monastery Gates NODE.owner = 485628 N.title = Information sitedoclet N.owner = 17342 --> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Find_Nodes"> <tr><th class="nodelet_head"> <span class="title">Find Nodes</span><a href="?node=About The Find Nodes Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <ul class="spacey-list"> <li><a href="?node_id=6364;user=961">Nodes You Wrote</a></li> <li><a href="?node=My%20Watched%20Nodes">My Watched Nodes</a></li> <li><a href="?node=Super%20Search">Super Search</a></li> <li><a href="?node=Perl%20Monks%20User%20Search">List Nodes By Users</a></li> <li><a href="?node=Newest%20Nodes">Newest Nodes</a></li> <li><a href="?node=Recently%20Active%20Threads">Recently Active Threads</a></li> <li><a href="?node=Selected%20Best%20Nodes">Selected Best Nodes</a></li> <li><a href="?node=Best%20Nodes">Best Nodes</a></li> <li><a href="?node=Worst%20Nodes">Worst Nodes</a></li> <li><a href="?node=Saints%20in%20our%20Book">Saints in our Book</a></li> <li><a href="?op=randomnode">Random Node</a></li> </ul> <!-- args=(Find Nodes sitedoclet -USER 961) NODE.title = The Monastery Gates NODE.owner = 485628 N.title = Find Nodes sitedoclet N.owner = 17342 --> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Leftovers"> <tr><th class="nodelet_head"> <span class="title">Leftovers</span><a href="?node=About The Leftovers Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <ul class="spacey-list" id="user"></ul> <ul class="spacey-list" id="internal"> <li><a href="?node=The%20St.%20Larry%20Wall%20Shrine">The St. Larry Wall Shrine</a></li> <li><a href="?node=Offering%20Plate">Offering Plate</a></li> <li><a href="?node=Awards">Awards</a></li> <li><a href="?node=Quests">Quests</a></li> </ul> <ul class="spacey-list" id="external"> <li><a href="http://www.perl.org/">Perl</a></li> <li><a href="http://blogs.perl.org/">Perl Blogs</a></li> <li><a href="http://perl.com/">Perl.com</a></li> <li><a href="https://perl.theplanetarium.org/">Planet Perl</a></li> <li><a href="http://perlweekly.com/">Perl Weekly</a></li> <li><a href="http://jobs.perl.org/">Perl Jobs</a></li> <li><a href="http://www.pm.org/">Perl Mongers</a></li> <li><a href="http://perldoc.perl.org/">Perl documentation</a></li> <li><a href="https://metacpan.org/">MetaCPAN</a></li> <li><a href="http://cpan.perl.org/">CPAN</a></li> <li><a href="https://raku.org/">Raku</a></li> </ul> <!-- args=(Leftovers sitedoclet -USER_LINKS -TIL <span class="wikilink"><a href="?node_id=11156813">Today I Learned</a></span>) NODE.title = The Monastery Gates NODE.owner = 485628 N.title = Leftovers sitedoclet N.owner = 17342 --> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Voting_Booth"> <tr><th class="nodelet_head"> <span class="title">Voting Booth</span><a href="?node=About The Voting Booth Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <p>No recent polls found<br /> </td></tr> </tbody> <!-- Nodelet Break --> <tbody class="nodelet" id="Notices"> <tr><th class="nodelet_head"> <span class="title">Notices</span><a href="?node=About The Notices Nodelet" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <table> <tr><th></th><td>• <i><a class="hoverDate" href="?node_id=1131330" title="2025-03-24 08:23:38">erzuuli</a></i></td><!-- <td>[id://651530]</td> --><td>‥ <a href="?node=Anonymous%20Monk">Anonymous Monk</a>s are no longer allowed to use Super Search, due to an excessive use of this resource by robots.</td></tr> </table> </td></tr> </tbody> </table> <!-- End nodelets --> </td> <!--/nodelet handling code (monktainer)--> </tr> </table> </center> <!-- End main (monktainer)--> <br /> <br /> <div id="footer"> PerlMonks parthenogenetically spawned by <a href="?node=vroom">Tim Vroom</a>.<br/> PerlMonks somehow became entangled with <a href="http://www.perlfoundation.org">The Perl Foundation</a>. <a href="?node=Offering%20Plate">Donate</a> to TPF!<br /> Speedy Servers and Bandwidth Generously Provided by <a href="http://promote.pair.com/direct.pl?perlmonks.org"> pair Networks</a> <br/>Built with the <a href="http://perl.org">Perl programming language</a>. </div> <!-- /monktainer --> </body> </html>