CINXE.COM

Meditations

<!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> Meditations </title> <link rel="canonical" href="https://www.perlmonks.org/?node_id=480" /> <!-- 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" /> </head> <body id="id-480"> <!-- 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%" > Welcome to the Monastery </td> </tr> <tr class="titlebar"> <td class="titlebar"> <form method="get" action="?" enctype="application/x-www-form-urlencoded" > &nbsp; <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>&nbsp;&nbsp; </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">Meditations</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&nbsp;in</a></li><li><a href="?node_id=101">Create&nbsp;a&nbsp;new&nbsp;user</a></li> <li><a href="?">The&nbsp;Monastery&nbsp;Gates</a></li> <li><a href="?node=Seekers%20of%20Perl%20Wisdom">Seekers&nbsp;of&nbsp;Perl&nbsp;Wisdom</a></li> <li><a href="?node=Meditations">Meditations</a></li> <li><a href="?node=Cool%20Uses%20for%20Perl">Cool&nbsp;Uses&nbsp;For&nbsp;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&nbsp;News</a></li> <li><a href="?node=Recently%20Active%20Threads">Recent&nbsp;Threads</a></li> <li><a href="?node=Newest%20Nodes">Newest&nbsp;Nodes</a></li> <li><a href="?node=Super%20Search">Super&nbsp;Search</a></li> <li><a href="?node=Perl%20Monks%20Discussion">PerlMonks&nbsp;Discussion</a></li> <li><a href="?node=Tidings">What's&nbsp;New</a></li> </ul> <!-- args=(monktitlebar sitedoclet -TOPNAV_SPECIAL <li><a href="?node_id=109">Log&nbsp;in</a></li><li><a href="?node_id=101">Create&nbsp;a&nbsp;new&nbsp;user</a></li>) NODE.title = Meditations 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=480">&#091;id://480&#093;</a>=<a href="?node_id=14">superdoc</a>: <a rel="nofollow" href="?displaytype=print;node_id=480">print</a> <a rel="nofollow" href="?node_id=480;replies=1;displaytype=print">w/replies</a>, <a href="?node_id=480;displaytype=xml">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 --> <link rel="alternate" type="application/rss+xml" href="?node_id=30175;xmlstyle=rss;types=perlmeditation" /><p> If you've discovered something amazing about Perl that you just need to share with everyone, this is the right place. </p><p> This <a href="/?node_id=674621" title="What are PerlMonks sections?">section</a> is also used for <em>non-question</em> discussions about Perl, and for any discussions that are not specifically programming related. For example, if you want to share or discuss opinions on hacker culture, the job market, or <a href="http://dev.perl.org/perl6/">Perl 6</a> development, this is the place. (Note, however, that discussions about the PerlMonks <i>web site</i> belong in <a href="?node_id=1040">PerlMonks Discussion</a>.) </p><p> <a href="?node=Meditations">Meditations</a> is sometimes used as a sounding-board &mdash; a place to post initial drafts of perl tutorials, code modules, book reviews, articles, quizzes, etc. &mdash; so that the author can benefit from the collective insight of the monks before publishing the finished item to its proper place (be it <a href="?node_id=954">Tutorials</a>, <a href="?node_id=1044">Cool Uses for Perl</a>, <a href="?node_id=21144">Reviews</a>, or whatever). If you do this, it is generally considered appropriate to prefix your node title with "RFC:" (for "request for comments"). </p> <!-- args=() NODE.title = Meditations NODE.owner = 485628 N.title = Meditations sitedoclet N.owner = 17342 --> <!-- 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%"> User Meditations </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <!-- BEGIN embed node with vote container --> <!-- 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-id11162831" name="post-head-id11162831" href="?node_id=11162831" >perlrun doc inaccurate on -s switch</a> <br/> <!-- REPLIES --> 2 direct replies &mdash; <a href="?node_id=11162831">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=174111">Discipulus</a> <br/> <!-- DATE --> on Nov 22, 2024 at 04:53 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul>Hello!<p> yesterday I was trying some perl <a href="?node_id=11162825">code</a> after neverending boring weeks (workwise..) and I tried to use <tt class='inlinecode'>-s</tt> to add <i>rudimentary</i> switch parsing as described <a href="https://perldoc.perl.org/perlrun#-s">here</a> (emphasis added by me):<p> <i>&gt; -s enables rudimentary switch parsing for switches on the command line after the program name but <u>before</u> any filename arguments (or <u>before</u> an argument of --).</i><p> The above is <b>true</b> when there is a real file containing a perl program:<p> <pre class="code"><div class='codeblock'><tt class='codetext'>echo print join &#39; &#39;, $0, $R &gt; switch-test.pl # after the program name perl -s switch-test.pl -R=OK switch-test.pl OK # before an argument of -- perl -s switch-test.pl -R=OK -- switch-test.pl OK # wrong usage perl -s switch-test.pl -- -R=OK switch-test.pl </tt></div><div class='embed-code-dl'><a href="?abspart=1;displaytype=displaycode;part=2;node_id=11162831">&#91;download&#93;</a></div></pre> <p> But what if the program is just some code passed with <tt class='inlinecode'>-e</tt> (and this is a valid program also for the program name perl's internal value)?<p> Even with my limited English understanding, I'd suppose something like: <tt class='inlinecode'>perl -s -e &quot;print $R&quot; R=a</tt> or <tt class='inlinecode'>perl -s -e -n &quot;print $R&quot; R=a filename</tt> (before any filename arguments) but no, it works exactly in the opposite way:<p> <pre class="code"><div class='codeblock'><tt class='codetext'># after the program name perl -s -e &quot;print join &#39; &#39;, $0, $R&quot; -R=OK Unrecognized switch: -R=OK (-h will show valid options). # before an argument of -- perl -s -e &quot;print join &#39; &#39;, $0, $R&quot; -R=OK -- Unrecognized switch: -R=OK (-h will show valid options). # it works in the opposite way of what perlrun states perl -s -e &quot;print join &#39; &#39;, $0, $R&quot; -- -R=OK -e OK </tt></div><div class='embed-code-dl'><a href="?abspart=1;displaytype=displaycode;part=6;node_id=11162831">&#91;download&#93;</a></div></pre> <p> So, given the switch is stated as <u>rudimentary</u> one should expect to use with small oneliners (only our dead pope used it as signature..) and not for serious programs.<p> In combination with other switches is even unfriendly: <pre class="code"><div class='codeblock'><tt class='codetext'>perl -snwe &quot;print join &#39; &#39;, $0, $R, $/&quot; -- -R=OK lorem.txt -e OK -e OK -e OK -e OK </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11162831;displaytype=displaycode;part=7">&#91;download&#93;</a></div></pre> <p> ..as it shuold be put <u>before</u> any file name but <u>after</u> the <tt class='inlinecode'>--</tt><p> The docs also warns about warnings:<p> <i>&gt; Also, when using this option on a script with warnings enabled you may get a lot of spurious "used only once" warnings.</i><p> ..but no... or.. what happens?? <pre class="code"><div class='codeblock'><tt class='codetext'>perl -wse &quot;print join &#39; &#39;, $0, $R&quot; -- -R=OK -e OK perl -swe &quot;print join &#39; &#39;, $0, $R&quot; -- -R=OK -e OK perl -sew &quot;print join &#39; &#39;, $0, $R&quot; -- -R=OK #what the hell?! ..no output :) </tt></div><div class='embed-code-dl'><a href="?displaytype=displaycode;part=9;node_id=11162831;abspart=1">&#91;download&#93;</a></div></pre> <p> I think the doc should metion the above. More: in this sight also <a href="https://perldoc.perl.org/perlrun#Command-Switches">--</a> is poorly documented.<p> Whant some monk put a pr somewhere or point me, lazy peon, to the correct repository to strike?<p> Have a nice weekend!<p> L*<p> <div class="pmsig"><div class="pmsig-174111"> There are no rules, there are no thumbs..<br /> Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS. </div></div><!-- Wiki2Monks {"version":1.161} --></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11162363" name="post-head-id11162363" href="?node_id=11162363" >What&#39;s happening with the Cygwin project?</a> <br/> <!-- REPLIES --> 4 direct replies &mdash; <a href="?node_id=11162363">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=19724">Intrepid</a> <br/> <!-- DATE --> on Oct 22, 2024 at 14:25 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>What's happening with the Cygwin project?</p> <p>I recall recently seeing a remark (on a node I cannot find now) wherein the monk asked "is Cygwin still supported?" That&#39;s a good question. Certainly cygwinPerl seem to be alive and current on the Cygwin download servers (at the time of this writing, v5.40.0). But a mechanism for asking questions about Cygwin in general is seemingly problematic and has been for a while. The Cygwin website is completely out of date, directing users to mailing lists that do not exist anymore. Apparently to reach Cygwin developers one must use <span class="caps">NNTP </span>(we&#39;re talking old school here).</p> <p>The <a href="http://cygwin.com">Cygwin.com</a> site says: "Please note that the gmane website and its newsgroup search interface is down since August 2016. Only the aforementioned <span class="caps">NNTP </span>gateway is still up."</p> <p>I see a fair amount of traffic in Cygwin questions on StackOverflow and its related sites, and if someone were to ask me where to get general help with Cygwin today, that&#39;s where I would direct them.</p> Oct 22, 2024 at 18:07&nbsp;UTC <div class="pmsig"><div class="pmsig-19724"> Examine what is said, not who speaks. <br />Love the truth but pardon error. <br />Silence betokens consent. <br />In the absence of evidence, opinion is indistinguishable from prejudice. </div></div></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11162278" name="post-head-id11162278" href="?node_id=11162278" >When Communities gets taken over</a> <br/> <!-- REPLIES --> 1 direct reply &mdash; <a href="?node_id=11162278">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=131279">talexb</a> <br/> <!-- DATE --> on Oct 15, 2024 at 08:54 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>The <a href="https://torment-nexus.mathewingram.com/is-matt-mullenweg-defending-wordpress-or-sabotaging-it/">Wordpress and Mullenweg</a> story popped up recently, and then just this morning, I read about <a href="https://phanpy.social/#/fosstodon.org/s/113307917552355298">Perforce and Puppet</a>, where it sounds like Perforce took over the Slack community of Puppet.</p> <p>The final comment in the Mastodon post was on point: <ul><i> .. has something happened behind the scenes in tech that I don't know about? Because everybody seems to be acting proper weird lately. </i></ul> It seems like takeovers for profit (like the IRC kerfuffle a while back -- I can't even remember the old server name) don't work. Are the lawyers taking over? Or is this just Chaos Theory/Entropy throwing us around a bit?</p> <div class="pmsig"><div class="pmsig-131279"> <p>Alex / <a href="?node=talexb">talexb</a> / Toronto</p> <p><small>Thanks PJ. We owe you so much. <a href="http://www.groklaw.net">Groklaw</a> -- RIP -- 2003 to 2013.</small></p> </div></div></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11161880" name="post-head-id11161880" href="?node_id=11161880" >Edge case for checkboxes when used to update data records</a> <br/> <!-- REPLIES --> 3 direct replies &mdash; <a href="?node_id=11161880">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=200239">davebaker</a> <br/> <!-- DATE --> on Sep 20, 2024 at 15:56 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>I spent many hours trying to solve a problem, found a solution, and would like to share it in case others might encounter it.</p> <p>A checkbox that appears on a form on an HTML page has a "name" attribute. Typically it has a "value" attribute. (If there is no "value" attribute, the default is for the web browser to send the string "on", I think, if the user has checked the checkbox before submitting the form.)</p> <p>Anyway, if it unchecked, naturally there is no value sent to the script that's receiving the submitted form data. Let's say the HTML in the form states that the name of the checkbox is "member." If the user is a member of a certain civic organization, as explained elsewhere on the web page, the web page asks the user to so advise the website owner by checking the checkbox. If not a member, then the user just leaves the checkbox unchecked.</p> <p>The interesting part is that the script receiving the form data has no idea whether there was a a checkbox named "member" unless the checkbox had been checked by the user. If it was left unchecked, the script doesn't get a "&amp;member=''" (empty string) or even a "&amp;member" in the submitted query string.</p> <p>Let's say the script uses the submitted data to add the user to a database. Probably a record in a table in a relational database. The script can be written to assume that the person is not to be recorded as a "member" of the civic organization if there is no value coming in for the "member" parameter. If so, the script inserts a record in the table, puts the empty string (or NULL) into the record's "member" field (here, the field in the table happens to be the same as the name of the form parameter), and life is good.</p> <p>But let's say the new user is indeed a member of the civic organization, and said so by checking the checkbox. So the script stores a "1" in the member field of the new record.</p> <p>OK. Next step: provide for the editing of the record. We want to have the script create an editing form that looks like the new-user form. The script pulls the user's record from the database, sees there is a value in the member field, and hence the form is created to include "checked=CHECKED" as an attribute, e.g., &lt;input type="checkbox" name="member" checked=CHECKED&gt; is somewhere in the form.</p> <p>But it's been six months since the user registered as a new user, and during that time she decided to let her membership in the civic organization lapse. So she wants to use the editing screen to update her record -- to literally uncheck the "member" checkbox. She does so, and submits the form.</p> <p>The script, because it doesn't receive any information about the member checkbox from the user's web browser (see above), has to ASSUME that a parameter named member was in the form, and that the failure to find any submitted value associated with that parameter, or find the parameter in the first place, means the user is wanting to have her record in the database updated so as to replace "1" with "0" (or the empty string, etc.). OK, no big deal. The code is fairly simple.</p> <p>But what if there were a different form presented to the user. One that is designed to let her change only her username, for example, and doesn't include the "member" checkbox. The HTML in the form is written to submit the data to the same script. But because the script has been written to assume that no incoming data for "member" means the person is no longer a member, then there's trouble when the script updates her record to change the "1" to "0" in the member field. The user only wanted to change her username.</p> <p>OK, so we revise the script to make no such assumption. Now, though, how will the script know when to change the "member" field from "1" to "0"? It can't assume that every form has given the user a "member" checkbox. This is the assumption that's been made in every code example that I've seen, though.</p> <p>The solution seems to be to have the form include a hidden input field that lists the names of all of the checkboxes in the form, so the script can safely assume that they're to be treated as having been submitted and they're to be treated as if the user intended them to be unchecked when the form was submitted. This can be done by printing a <tt class='inlinecode'>&lt;input type=hidden value=&quot;member&quot;&gt;</tt> line somewhere inside the <tt class='inlinecode'>&lt;form ...&gt; and &lt;/form&gt;</tt> tags.</p> <p>I used the CGI.pm module to create a form, used its checkbox() function to print a checkbox inside it, and found that, lo and behold, the HTML includes a line that says something like <tt class='inlinecode'>&lt;input type=&quot;hidden&quot; name=&quot;.cgiparams&quot; value=&quot;member&quot;&gt;</tt> just before the <tt class='inlinecode'>&lt;/form&gt;</tt> tag. I had successfully reinvented the wheel.</p> <p>CGI.pm is then able to redisplay the form (if, for example, the user supplied invalid data in the form such that the script is written to redisplay the form along with an error message), and the stickiness aspect of its created checkboxes means that a checkbox that initially was displayed as being checked will be correctly redisplayed as being unchecked if the user had in fact unchecked the checkbox before submitting the form. CGI.pm apparently knows that the checkbox it creates upon redisplay of the form is not to be checked this time, because it finds the member parameter in the .cgiparams list that was part of the submitted form and it determines that no value came in for the member parameter (or that the parameter didn't come in at all).</p> <p>My strategy in generating web forms has been to take advantage of CGI.pm's sticky checkboxes and to use HTML::Template for templates. (I don't want to use CGI.pm to create and display the entire form using the 1995-ish technique of <tt class='inlinecode'>$q-&gt;start_html; $q-&gt;start_form &#91;etc.&#93;; $q-&gt;end_form; $q-&gt;end_html;</tt> in the script, even if that seems to have been a good and novel idea back in the day.)</p> <p>So my script creates a sticky checkbox by calling <tt class='inlinecode'>$q-&gt;checkbox( -name =&gt; &quot;member&quot; )</tt>. CGI.pm returns a string of HTML that can be sent over to the template, where there is a <tt class='inlinecode'>&lt;TMPL_VAR MEMBER_CHECKBOX&gt;</tt> embedded in its text, waiting to receive the HTML for the checkbox, which might be checked due to CGI.pm's stickiness, or might not be.</p> <p>Alas, the sticky feature still wasn't working. A "view source" revealed that the magic <tt class='inlinecode'>&lt;input type=&quot;hidden&quot; name=&quot;.cgiparams&quot; value=&quot;member&quot;&gt;</tt> wasn't part of the form in the generated web page. But, of course, why should it be? I hadn't sent it over to the template. But where is CGI.pm generating that string? How do I get it?</p> <p>It turns out that the string containing the hidden list of fields is prepended to <tt class='inlinecode'>&lt;/form&gt;</tt> when CGI.pm's <tt class='inlinecode'>$q-&gt;end_form()</tt> is called. But beware (ask me how I know), this is the case only if <tt class='inlinecode'>$q-&gt;start_form()</tt> has been called before <tt class='inlinecode'>$q-&gt;checkbox()</tt> was called. it's not enough that the CGI module was instantiated. My template had its own <tt class='inlinecode'>&lt;form action=&quot;https://yaddayadda.com/script.cgi&quot;&gt;</tt> and its own <tt class='inlinecode'>&lt;/form&gt;</tt> tag, so I hadn't thought of using needing to call <tt class='inlinecode'>CGI-&gt;start_form()</tt> or <tt class='inlinecode'>CGI-&gt;end_form()</tt>. I only needed the creation of the sticky checkboxes.</p> <p>What wasn't intuitive to me, and might be useful to others, is that I needed to have my script actually call something like <tt class='inlinecode'>my $throwaway_string = $q-&gt;start_form();</tt> somewhere before <tt class='inlinecode'>$template-&gt;param( MEMBER_CHECKBOX =&gt; $q-&gt;checkbox(-name =&gt; &quot;member&quot;) );</tt> and then needed to send over the list of hidden fields by doing something like <tt class='inlinecode'>my $hidden_list_of_fields_and_closing_form_tag = $q-&gt;end_form();</tt> -- after the last checkbox or any other form field had been created by using a CGI.pm function -- followed by something like <tt class='inlinecode'>$template-&gt;param( HIDDEN_LIST_OF_FIELDS_AND_CLOSING_FORM_TAG =&gt; $hidden_list_of_fields_and_closing_form_tag );</tt></p> <p>I don't need to send over the results of start_form(); I just need to have called it. The sticky checkboxes work even with the <tt class='inlinecode'>&lt;form action=...&gt;</tt> that's hard-coded in my template. But apparently I do need to call start_form() in order for CGI.pm to start paying attention and keeping a list of the names of the checkboxes (or other HTML form elements) that it's thereafter creating, so that <tt class='inlinecode'>$q-&gt;end_form()</tt> knows what to return in the way of a hidden list of fields.</p> <p>I know that a web application platform might handle this particular edge case behind the scenes, but I'm not sure. I've done some development with Dancer2, but even that fine platform seems to assume that the developer has picked and implemented some Perl module (ideally, one that's more recent and more sophisticated than CGI.pm) to handle the creation of form elements, and to somehow handle this checkbox edge case.</p> <hr /> <p>Edited for clarity, probably unsuccessfully due to author's inability to communicate precisely :-)</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11160680" name="post-head-id11160680" href="?node_id=11160680" >The intersection of M hyperplanes (Ndim)</a> <br/> <!-- REPLIES --> 4 direct replies &mdash; <a href="?node_id=11160680">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1165397">bliako</a> <br/> <!-- DATE --> on Jul 18, 2024 at 09:41 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>Here is my understanding of what the theory behind what I am trying to do is, correct me where I am wrong, also please check my questions at the end:</p> <p>The intersection of N hyperplanes (Ndim) is also known as the solution to "the system of N linear equations(=planes) with N variables". However, I am interested in the case when I have less equations. The result is not a single point in Ndim but a lower-dimensions plane. For example in 3D. The intersection of 3 planes (M=3, N=3), assuming any pair is not parallel, is a single 3D point and the intersection of 2 planes (M=2, N=3) is a line. In Ndim, the solution would be an Mdim hyperplane "living" in Ndim. Below, I call this a "hyperline".</p> <p>An example of the above problem is in this <a href="https://math.stackexchange.com/questions/475953/how-to-calculate-the-intersection-of-two-planes">SO question</a>. The result is the equation of the intersection line in parametric form. Arbitrary values of the parameter <tt class='inlinecode'>t</tt> yields a point on this line. Ideally this is what I want to achieve: finding points on the intersection of the planes.</p> <p>Solving the system of N linear equations with N variables (Ndim) can be done with, for example, <a href="https://metacpan.org/pod/Math%3A%3AMatrix">Math::Matrix</a>. Given N planes in the form <tt class='inlinecode'>a1x+b1y+c1z+...n1=0</tt> etc., a matrix A is formed with each row being <tt class='inlinecode'>&#91;a1, b1, c1, ..., n1&#93;</tt> etc. then: <tt class='inlinecode'>Math::Matrix-&gt;new(&#91;&#91;a1,b1,c1,...,n1&#93;,...&#93;)-&gt;solve-&gt;print;</tt> </p> <p>I have experimented with <tt class='inlinecode'>solve()</tt> for the case of M linear equations (Ndim) where M = N-1:</p> <pre class="code"><div class='codeblock'><tt class='codetext'>use Math::Matrix; Math::Matrix-&gt;new( &#91;1, 2, 1, -1&#93;, # ax+by+cz+n=0 &#91;2, 3, -2, 2&#93; )-&gt;solve-&gt;print; # says # -7.00000 7.00000 # 4.00000 -4.00000 </tt></div><div class='embed-code-dl'><a href="?abspart=1;part=6;displaytype=displaycode;node_id=11160680">&#91;download&#93;</a></div></pre> <p>I interpret the result as: the 1st row refers to the 1st dim (aka x) and we have <pre class="code"><div class='codeblock'><tt class='codetext'>x -7*t + 7 = 0 =&gt; x = 7*t - 7 </tt></div><div class='embed-code-dl'><a href="?abspart=1;part=7;displaytype=displaycode;node_id=11160680">&#91;download&#93;</a></div></pre> The 2nd row yields <pre class="code"><div class='codeblock'><tt class='codetext'>y + 4*t -4 = 0 =&gt; y = -4*t + 4 </tt></div><div class='embed-code-dl'><a href="?abspart=1;part=8;displaytype=displaycode;node_id=11160680">&#91;download&#93;</a></div></pre> and the missing 3rd dim is the parameter t itself: <tt class='inlinecode'>z = t</tt>. And I can get a point on that line by setting <tt class='inlinecode'>t</tt> to an arbitrary value. I can verify that this point is on each plane by substituting the point's coordinates into each plane equation.</p> <p>I have also experimented with transforming the planes matrix to the <a href="https://en.wikipedia.org/wiki/Row_echelon_form">Reduced Row Echelon Form</a>. Which makes it convenient to work out the "hyperline" equation. This functionality is offered by <a href="https://metacpan.org/pod/Math%3A%3AMatrixLUP">Math::MatrixLUP</a> :</p> <pre class="code"><div class='codeblock'><tt class='codetext'>use Math::MatrixLUP; my @planes3D = ( &#91;1, 2, 1, -1&#93;, # ax+by+cz+n=0 &#91;2, 3, -2, 2&#93; ); print Math::MatrixLUP-&gt;new(\@planes3D)-&gt;rref # says # &#91;1, 0, -7, 7&#93;, # &#91;0, 1, 4, -4&#93; </tt></div><div class='embed-code-dl'><a href="?node_id=11160680;displaytype=displaycode;part=11;abspart=1">&#91;download&#93;</a></div></pre> <p>Which I interpret as: 1st row has 1 on 1st col, that's the 1st dim (aka x) : <pre class="code"><div class='codeblock'><tt class='codetext'>x -7 * t + 7 = 0 =&gt; x = 7*t-7 </tt></div><div class='embed-code-dl'><a href="?node_id=11160680;part=12;displaytype=displaycode;abspart=1">&#91;download&#93;</a></div></pre> etc.</p> <p>So that works well.</p> <p>Here is a demo I whipped up:</p> <div class='readmore-link'><a href="?node_id=11160680">Read more...</a><span class='readmore-size'> (9 kB)</span></div> <p>I have some questions:</p> <ul> <li>Two planes are parallel when their normal vectors (the coefficients of the dimensions: <tt class='inlinecode'>a, b, c, ...</tt> (but not the constant <tt class='inlinecode'>n</tt>) are multiples. E.g. <tt class='inlinecode'>nv1 = k * nv2</tt>. And this translates to checking if all the ratios of the coefficients : <tt class='inlinecode'>a1/a2 = b1/b2 = c1/c2 = ...</tt> are the same. My question is: what happens if any coefficient is zero (or actually both coefficients (e.g. a1 and a2) are zero?</li> <li>How can I calculate the intersection when M &lt; (N-1)? I.e. above I am always checking the intersection of M planes in Ndim where M = N-1. But what if there are even less planes? e.g. <pre class="code"><div class='codeblock'><tt class='codetext'>my @planes5D = ( &#91;1, 2, 1, -2, 3, -1&#93;, # ax+by+cz+n=0 &#91;2, 3, -2, 4, -4, 2&#93;, &#91;3, -1, -2, -5, 6, 2&#93;, # only 3 planes (it was successful with 4) ) </tt></div><div class='embed-code-dl'><a href="?abspart=1;displaytype=displaycode;part=18;node_id=11160680">&#91;download&#93;</a></div></pre> In short, does the parametric equation of the intersecting "hyperline" contain 2 parameters now?</li> <li>When I test <tt class='inlinecode'>test_in_beast_space</tt> which produces random planes in 666 dimensions, it fails to detect that a point on the intersection "hyperline" lies on all the planes. To do that I substitute the point in each plane equation and expect to have result as zero. However, it's not an exact zero. That's why I am doing a range test to check if it's close to zero. Well the closeness $SMALLNUMBER for 5 dimensions can be as small as 1E-09. But for these many dimensions it can be as low as 1E-02. Is the accuracy lost in summing 666 multiplications that much really? </li> <li>I guess <tt class='inlinecode'>Math::Matrix::solve()</tt> is safe to be used for MxN matrices (e.g. M equations=planes in N unknowns (dimensions) where M&lt;N)? From <a href="https://metacpan.org/pod/Math%3A%3AMatrix#solve%28%29">solve() of Math::Matrix</a> : <pre class="code"><div class='codeblock'><tt class='codetext'>Solves a equation system given by the matrix. The number of colums mus<span class="line-breaker"> <font color="red">+</font></span>t be greater than the number of rows. If variables are dependent from<span class="line-breaker"> <font color="red">+</font></span> each other, the second and all further of the dependent coefficients<span class="line-breaker"> <font color="red">+</font></span> are 0. This means the method can handle such systems. The method ret<span class="line-breaker"> <font color="red">+</font></span>urns a matrix containing the solutions in its columns or undef in cas<span class="line-breaker"> <font color="red">+</font></span>e of error. </tt></div><div class='embed-code-dl'><a href="?part=21;displaytype=displaycode;node_id=11160680;abspart=1">&#91;download&#93;</a></div></pre> </li> <li>The edge cases where the 1st dimension is zero for all planes in 5D and when the 1st+2nd are zero, fail. How can I find the intersection in this case?</li> </ul> <p>Edits: updated the demo to correct the sub <tt class='inlinecode'>are_planes_parallel()</tt> as per the comments of <a href="?node=hippo">hippo</a> and <a href="?node=LanX">LanX</a> about what happens when plane-equation coefficients are zero.</p> <p>have fun in beast space! bw bliako</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11160429" name="post-head-id11160429" href="?node_id=11160429" >Who&#39;s still around?</a> <br/> <!-- REPLIES --> 20 direct replies &mdash; <a href="?node_id=11160429">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=789891">stevieb</a> <br/> <!-- DATE --> on Jul 08, 2024 at 03:29 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>In 1998, a friend gave me a computer. It was in pieces. I knew nothing about nothing. Within a year, I was communicating over dual telephone lines. Within two years of that, I was a sysadmin at an ISP. This was the year I found Perlmonks. I read a book, 'Perl in 21 days' or some such, and found Perl was what I wanted... a way to automate processes.</p> <p>Within months, I learned a dangerous amount about MySQL, CGI and Perl to allow any invader to break everything. Thankfully, during that time, everyone was out for themselves, and exploitation hadn't yet become a thing.</p> <p>By 2009, I'd grown a lot in many areas. No where near perfect in the security arena, but I was becoming proficient on how to interact with the open source world, and how to interact with the CPAN. It was this year that I joined Perlmonks as a member, and became a vocal person, not just a listener.</p> <p>Now, as some of the old timers will attest to, I always claimed "I'm not a programmer". With that said, I have done much work in fields so closely related to programming, that I have to bend and say that yeah, maybe I can classify as a hacker.</p> <p>Anyone else around who have claimed "I'm not a programmer", or who has been around since the very early days of Perlmonks who would just like to say "I'm still here!!!"?.</p> <p>-stevieb</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11160406" name="post-head-id11160406" href="?node_id=11160406" >Houston Perl Mongers Meeting Announcement Email List (new)</a> <br/> <!-- REPLIES --> 1 direct reply &mdash; <a href="?node_id=11160406">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=11133857">oodler</a> <br/> <!-- DATE --> on Jul 06, 2024 at 01:23 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><a href="https://crm.acutisdata.com/sendy/subscription?f=KruPzmUQwBBSOY4Q892JC9gk892dTlXT3GQHvtLh763jZX7iKu4ZjkKaryOe8bgYVSsO9a7892Xdc9QAP892NyYQVvDGkayg">Houston PM's private, self hosted email list</a> (using Sendy/AWS SES - PHP sorry xD) - monthly meeting announcements will be from <b>noreply@houstonperlmongers.org</b> and reply-to is to <b>brett.estrade@gmail.com</b>. I'm working getting the link/form up on the Houston Perl Mongers site, <b>https://houstonperlmongers.org</b> (or houston.pm.org). Keeping up with all the outlets is too much, so going back to email and website announcements. I may still post here; July's meeting has not yet been set. <br /> <br /> Cheers</ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11160309" name="post-head-id11160309" href="?node_id=11160309" >Generate random strings from regular expression</a> <br/> <!-- REPLIES --> 4 direct replies &mdash; <a href="?node_id=11160309">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1165397">bliako</a> <br/> <!-- DATE --> on Jul 02, 2024 at 06:41 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>I needed to generate random strings from a regular expression and I have found (*) a C++ library (<a href="https://github.com/daidodo/regxstring">regxstring C++ library by daidodo</a>) which does just that and works fine for my use case. It claims that it supports most Perl 5 regexp syntax. It is quite fast too. So I have ported it into a Perl module, here : <a href="https://metacpan.org/pod/String%3A%3ARandom%3A%3ARegexp%3A%3Aregxstring">String::Random::Regexp::regxstring</a>.</p> <pre class="code"><div class='codeblock'><tt class='codetext'>perl -MString::Random::Regexp::regxstring -e &#39;print @{generate_random_<span class="line-breaker"> <font color="red">+</font></span>strings(q{^\d{3}&#91;-,.&#93;&#91;A-V&#93;&#91;a-z&#93;{3}\d{2}})};&#39; </tt></div><div class='embed-code-dl'><a href="?node_id=11160309;displaytype=displaycode;part=1;abspart=1">&#91;download&#93;</a></div></pre> <pre class="code"><div class='codeblock'><tt class='codetext'>use String::Random::Regexp::regxstring; my $strings = generate_random_strings(&#39;^&#91;a-c&#93;{2}&#91;-,.&#93;\d{3}-&#91;A-Z&#93;{2}$&#39;,<span class="line-breaker"> <font color="red">+</font></span> 10); print &quot;@$strings\n&quot; </tt></div><div class='embed-code-dl'><a href="?displaytype=displaycode;part=2;node_id=11160309;abspart=1">&#91;download&#93;</a></div></pre> <p>The XS and C++ code bridging Perl to C++ library are very simple and can serve as an example for doing that for other libraries. Go forth and multiply.</p> <p>(*) Via this <a href="?node_id=284513">old thread</a> I found <a href="https://metacpan.org/pod/Regexp%3A%3AGenex">Regexp::Genex</a> and there is also <a href="https://metacpan.org/pod/String%3A%3ARandom">String::Random</a>. Neither worked for my use case.</p> <p>bw, bliako</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11160145" name="post-head-id11160145" href="?node_id=11160145" >&#91;OT&#93; Smartphone IO interface: how to control motors and read sensors</a> <br/> <!-- REPLIES --> 2 direct replies &mdash; <a href="?node_id=11160145">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1165397">bliako</a> <br/> <!-- DATE --> on Jun 21, 2024 at 06:46 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>I was thinking what my options are for controlling a remote farm remotely.</p> <p>I needed to do basic stuff like run the motor to push the feed to the animals, open a valve to let mains water fill their drinking buckets, check feed and water levels, check temperature. Even count the number of eggs.</p> <p>The farm <del>has no electricity</del> is off-grid and has no alternative power installed, so it must rely on solar energy. I want to minimise the use of batteries. There is no WIFI, but it is covered by the national 4,5G telephone network.</p> <p>A smartphone has all the communication modules available and ready: sms, voice, data, bluetooth, even rfid. It also has a good power supply and provided is not loaded with apps, it can last for 24 hours at least for the next sunshine for the solar charger to work. And it allows high-level programming.</p> <p>Unfortunately a smartphone lacks any connectivity to the world by means of IO ports. And so I am looking for an IO board to the smartphone via its USB or perhaps the bluetooth. The cheaper the better really and simpler too.</p> <p>I found <a href="https://github.com/ytai/ioio/wiki">IOIO-OTG</a> which interfaces android-based smartphone or PC via usb to a lot of IO ports which can read sensors or run motors and actuators.</p> <p>I really like an IO board+Smartphone solution because I can sms to it commands like "feed animals" or "count eggs". And it can reply back via sms. I can also command it via internet ("data") and perhaps get the odd picture back. There is solar charging available and cheap. And with just a single app running perhaps it can manage 24hrs recharge cycles. From all of the above I love the control-by-sms idea.</p> <p>My first point of call was the raspberry but i would prefer that there was a plugin module to the pi to do that rather than buying cells+batteries and doing calculations. E.g. <a href="https://community.element14.com/products/raspberry-pi/f/forum/53345/power-raspberry-pi-using-solar-panel">https://community.element14.com/products/raspberry-pi/f/forum/53345/power-raspberry-pi-using-solar-panel</a></p> <p>I would also like to communicate with the device. The most reliable way I see is via SMS. And the most practical is via 5G internet (data). The PI offers <a href="https://www.industrialshields.com/blog/raspberry-pi-for-industry-26/how-to-send-and-receive-sms-with-raspberry-pi-automation-305">sending SMS</a> but again, it's hands-on and a lot can go wrong.</p> <p>So, I am looking for recommendations on other IO boards for smartphones (android is just fine), and/or similar solutions for the PI just to be fair to the PI, if people feel that's a better environment.</p> <p>I have asked hacker news about this <a href="https://news.ycombinator.com/item?id=40747841">here</a></p> <p>thanks, bw, bliako</p> <p>edit:the IOIO-OTG board needs own power supply when plugged into smartphone. Not when plugged into PC</p> <p>Edit 27/06/2024: I have read that when connecting the board to smartphone (not PC) it must provide its own power supply. It can not be powered from Android. Android then asks you if you want to charge the phone with what it found on its USB port or transfer photos etc. This fits well with the design that the board has its own solar power+battery which then charges the phone as well, and also drives any external motors (TODO: noise from motors into the board). If external power runs out (no sun for days) then, firstly, the board stops and then the phone runs out of its own battery (sending an sms to me when in the critical zone) after a while. When solar power recharges on sun appearing, the board will be able to charge the phone too. Problem I see, how to turn the phone on when power comes back and how to tell it that what is on the USB port (our IO board) should be run on the specified mode (transfer files, charge, whatever) WITHOUT user intervention. Just by its own.</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159849" name="post-head-id11159849" href="?node_id=11159849" >XS: How to call another Perl function/method with same arguments</a> <br/> <!-- REPLIES --> 1 direct reply &mdash; <a href="?node_id=11159849">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1068773">etj</a> <br/> <!-- DATE --> on Jun 09, 2024 at 11:48 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul>Recently in PDL I was reimplementing often-used Perl functions in XS for <i>raw speed gainz</i>. A problem I dealt with was effectively dispatching to another Perl method in some circumstances with the same Perl arguments, as efficiently as possible. <p>I'll leave out how it took a couple of days of experimenting to figure this out; that wasn't due to the dispatching technique being wrong, but a simple logic error a bit further up the function. If there's any value to mentioning that here, it's to check your assumptions (possibly with <tt class='inlinecode'>printf</tt>) when things don't go to expectations. <p>The obvious way to do this, according to <a href="https://perldoc.perl.org/perlcall">https://perldoc.perl.org/perlcall</a>, is to pass the <tt class='inlinecode'>G_NOARGS</tt> flag. However, that is (somewhat obscurely) documented as not being a good idea to use with <tt class='inlinecode'>perl_call_method</tt>. The technique I settled on, permalinked at <a href="https://github.com/PDLPorters/pdl/blob/cd5ffff1b85ff81effefc2085067e9d71801efd6/Basic/Core/Core.xs#L199-L220">https://github.com/PDLPorters/pdl/blob/cd5ffff1b85ff81effefc2085067e9d71801efd6/Basic/Core/Core.xs#L199-L220</a>: <pre class="code"><div class='codeblock'><tt class='codetext'> SP -= items; PUSHMARK(SP); SPAGAIN; /* these pass this set of ar<span class="line-breaker"> <font color="red">+</font></span>gs on */ int retvals = perl_call_method(&quot;new&quot;, G_SCALAR); SPAGAIN; if (retvals != 1) barf(&quot;new returned no values&quot;); RETVAL = POPs; </tt></div><div class='embed-code-dl'><a href="?node_id=11159849;displaytype=displaycode;part=4;abspart=1">&#91;download&#93;</a></div></pre> For completeness, this is the full text of the function: <pre class="code"><div class='codeblock'><tt class='codetext'>SV * topdl(klass, arg1, ...) SV *klass; SV *arg1; CODE: if (items &gt; 2 || (!SvROK(arg1) &amp;&amp; SvTYPE(arg1) &lt; SVt_PVAV) || (SvROK(arg1) &amp;&amp; SvTYPE(SvRV(arg1)) == SVt_PVAV) ) { SP -= items; PUSHMARK(SP); SPAGAIN; /* these pass this set of ar<span class="line-breaker"> <font color="red">+</font></span>gs on */ int retvals = perl_call_method(&quot;new&quot;, G_SCALAR); SPAGAIN; if (retvals != 1) barf(&quot;new returned no values&quot;); RETVAL = POPs; } else if (SvROK(arg1) &amp;&amp; SvOBJECT(SvRV(arg1))) { RETVAL = arg1; } else { barf(&quot;Can not convert a %s to a %s&quot;, sv_reftype(arg1, 1), SvPV_n<span class="line-breaker"> <font color="red">+</font></span>olen(klass)); } SvREFCNT_inc(RETVAL); OUTPUT: RETVAL </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11159849;part=5;displaytype=displaycode">&#91;download&#93;</a></div></pre> <b>EDIT</b> to explain the magic a bit more: <tt class='inlinecode'>SP</tt> is the <i>local copy</i> (which Perl does for efficiency when you repeatedly push arguments) of the global current "Perl stack pointer" (as I am calling it here): the address of <tt class='inlinecode'>ST(items-1)</tt> for <i>the next function called</i>, i.e. the top of the current stack frame. When you <tt class='inlinecode'>PUSHMARK</tt> an address, that will be <tt class='inlinecode'>ST(0)</tt> for the <i>next Perl function</i> that gets called. <tt class='inlinecode'>items</tt> for that next function will be the global "Perl stack pointer" minus that next function's <tt class='inlinecode'>ST(0)</tt> (plus 1). <tt class='inlinecode'>SPAGAIN</tt> copies the global "Perl stack pointer" into <tt class='inlinecode'>SP</tt> - I am carefully not saying "copies back", because of the faintly tricky stuff done here. <p>Breaking the code into individual statements, with comments for each: <pre class="code"><div class='codeblock'><tt class='codetext'>SP -= items; /* make the local SP point at our ST(0) */ PUSHMARK(SP); /* make the next function&#39;s ST(0) be that */ SPAGAIN; /* reset our local SP to the global &quot;top of current stack&quot; */ int retvals = perl_call_method(&quot;new&quot;, G_SCALAR); /* call method so has<span class="line-breaker"> <font color="red">+</font></span> right stack frame */ SPAGAIN; /* set our local SP to the global &quot;top of current stack&quot; */ if (retvals != 1) barf(&quot;new returned no values&quot;); /* use croak in non-<span class="line-breaker"> <font color="red">+</font></span>PDL code */ RETVAL = POPs; /* set the SV* to the return value */ </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11159849;displaytype=displaycode;part=14">&#91;download&#93;</a></div></pre> You may think, as I have just realised in writing this, that the first 3 lines do unnecessary work, since <tt class='inlinecode'>PUSHMARK(SP - items)</tt> would valuably replace them. You would be right! And I have just done this. However, leaving this example as it is still seems valuable (and the generated machine code is likely to be extremely similar), so I am doing so.</ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159837" name="post-head-id11159837" href="?node_id=11159837" >a nifty utility script from chatgpt</a> <br/> <!-- REPLIES --> 4 direct replies &mdash; <a href="?node_id=11159837">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=947695">Aldebaran</a> <br/> <!-- DATE --> on Jun 09, 2024 at 04:18 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><i></i> <p>Hey monks,</p> <p>I'm backing up files with chatgpt and perl. I got a pretty good utility program out of it (them, whatever). It's a utility to sort pics and convert .heic to .jpg. I happen to be looking for a particular picture I took in 2021, so this is really helpful. Typical output:</p> <pre class="code"><div class='codeblock'><tt class='codetext'> Moved and renamed: /home/fritz/Pictures/6.pics/2022-12-08-220201009.mp<span class="line-breaker"> <font color="red">+</font></span>4 -&gt; /media/hogan/175F-DC61/Organized_Pics/2022/12/2022_12_08_5.mp4 Skipping: Wallpapers (not a file) Processing file: Screenshot from 2022-10-16 16-58-24.png File path: /home/fritz/Pictures/Wallpapers/Screenshot from 2022-10-16 <span class="line-breaker"> <font color="red">+</font></span>16-58-24.png Failed to delete original file /home/fritz/Pictures/Wallpapers/Screens<span class="line-breaker"> <font color="red">+</font></span>hot from 2022-10-16 16-58-24.png: No such file or directory Moved and renamed: /home/fritz/Pictures/Wallpapers/Screenshot from 202<span class="line-breaker"> <font color="red">+</font></span>2-10-16 16-58-24.png -&gt; /media/hogan/175F-DC61/Organized_Pics/2022/10<span class="line-breaker"> <font color="red">+</font></span>/2022_10_16_13.png Processing complete! Number of files created: 960 fritz@laptop:~/Documents$ </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11159837;displaytype=displaycode;part=1">&#91;download&#93;</a></div></pre> <p>Source:</p> <pre class="code"><div class='codeblock'><tt class='codetext'>#!/usr/bin/perl use strict; use warnings; use File::Find; use File::Path qw(make_path); use File::Copy qw(move); use POSIX qw(strftime); # Define the source and target directories my $source_dir = &#39;/home/fritz/Pictures&#39;; my $target_dir = &#39;/media/hogan/175F-DC61/Organized_Pics&#39;; # Check if the source directory exists unless (-d $source_dir) { die &quot;Source directory $source_dir does not exist.\n&quot;; } # Create the target directory if it doesn&#39;t exist unless (-d $target_dir) { make_path($target_dir) or die &quot;Failed to create target directory $<span class="line-breaker"> <font color="red">+</font></span>target_dir: $!\n&quot;; print &quot;Created target directory: $target_dir\n&quot;; } # Hash to store file type counts my %file_types; my $file_count = 0; # Subroutine to process each file sub process_file { if (-f $_) { my ($ext) = $_ =~ /\.(&#91;^.&#93;+)$/; $ext = lc $ext if defined $ext; # Convert to lowercase if (defined $ext &amp;&amp; $ext =~ /^(jpg|jpeg|png|gif|bmp|tiff|heic|<span class="line-breaker"> <font color="red">+</font></span>mp4)$/) { print &quot;Processing file: $_\n&quot;; my $file_path = $File::Find::name; print &quot;File path: $file_path\n&quot;; my $mod_time = (stat($file_path))&#91;9&#93;; my $date = strftime &quot;%Y_%m_%d&quot;, localtime($mod_time); my ($year, $month, $day) = split(&#39;_&#39;, $date); my $dest_dir = &quot;$target_dir/$year/$month&quot;; unless (-d $dest_dir) { make_path($dest_dir) or die &quot;Failed to create destinat<span class="line-breaker"> <font color="red">+</font></span>ion directory $dest_dir: $!\n&quot;; print &quot;Created destination directory: $dest_dir\n&quot;; } my $count = 1; my $new_file_name; if ($ext eq &#39;heic&#39;) { $new_file_name = &quot;${year}_${month}_${day}_$count.jpg&quot;; while (-e &quot;$dest_dir/$new_file_name&quot;) { $count++; $new_file_name = &quot;${year}_${month}_${day}_$count.j<span class="line-breaker"> <font color="red">+</font></span>pg&quot;; } my $converted_file_path = &quot;$dest_dir/$new_file_name&quot;; my $convert_command = &quot;heif-convert $file_path $conver<span class="line-breaker"> <font color="red">+</font></span>ted_file_path&quot;; system($convert_command) == 0 or die &quot;Failed to conver<span class="line-breaker"> <font color="red">+</font></span>t $file_path: $!\n&quot;; unlink $file_path or warn &quot;Failed to delete original f<span class="line-breaker"> <font color="red">+</font></span>ile $file_path: $!\n&quot;; print &quot;Converted and moved: $file_path -&gt; $converted_f<span class="line-breaker"> <font color="red">+</font></span>ile_path\n&quot;; } else { $new_file_name = &quot;${year}_${month}_${day}_$count.$ext&quot;<span class="line-breaker"> <font color="red">+</font></span>; while (-e &quot;$dest_dir/$new_file_name&quot;) { $count++; $new_file_name = &quot;${year}_${month}_${day}_$count.$<span class="line-breaker"> <font color="red">+</font></span>ext&quot;; } move($file_path, &quot;$dest_dir/$new_file_name&quot;) or die &quot;F<span class="line-breaker"> <font color="red">+</font></span>ailed to move file $file_path: $!\n&quot;; unlink $file_path or warn &quot;Failed to delete original f<span class="line-breaker"> <font color="red">+</font></span>ile $file_path: $!\n&quot;; print &quot;Moved and renamed: $file_path -&gt; $dest_dir/$new<span class="line-breaker"> <font color="red">+</font></span>_file_name\n&quot;; } $file_count++; } else { print &quot;Skipping file: $_ (not an image)\n&quot;; } } else { print &quot;Skipping: $_ (not a file)\n&quot;; } } # Find and process files in the source directory print &quot;Starting to process files in $source_dir...\n&quot;; find(\&amp;process_file, $source_dir); print &quot;Processing complete! Number of files created: $file_count\n&quot;; </tt></div><div class='embed-code-dl'><a href="?displaytype=displaycode;part=2;node_id=11159837;abspart=1">&#91;download&#93;</a></div></pre> <p>What bells and whistles might we coach it to add?</p> <p>Cheers from my own private Idaho,</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159541" name="post-head-id11159541" href="?node_id=11159541" >SO and AI</a> <br/> <!-- REPLIES --> 8 direct replies &mdash; <a href="?node_id=11159541">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=789891">stevieb</a> <br/> <!-- DATE --> on May 20, 2024 at 02:53 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>Stack just monetized all of the data that we, as public advocates of free information, provided.</p> <p>Is Perlmonks going to do this? If it is, I want all of my content removed immediately. I do not agree to the knowledge I've learned from those before me and I've subsequently shared being sold to anyone without due attribution.</p> <p>If Perlmonks plans on selling its user data to anyone, I outright refuse to take part, and want my data to be excluded entirely.</p> <p>-stevieb</p></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159421" name="post-head-id11159421" href="?node_id=11159421" >Bizarre copy of ARRAY etc - solved</a> <br/> <!-- REPLIES --> No replies &mdash; <a href="?node_id=11159421">Read more</a> | <a href="?parent=11159421;node_id=3333">Post response</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1068773">etj</a> <br/> <!-- DATE --> on May 13, 2024 at 17:07 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul>A simple XS function in PDL, <tt class='inlinecode'>firstvals_nophys</tt>, was giving "panic: attempt to copy freed scalar", but only if called on a complex-valued ndarray. The aim of this post is to appear when a despairing XS programmer googles that message, and give them another thing to check. When constructing a test to capture this, another message that appeared was "Bizarre copy of ARRAY". This is the old text of the function: <pre class="code"><div class='codeblock'><tt class='codetext'>void firstvals_nophys(x) pdl *x PPCODE: if (!(x-&gt;state &amp; PDL_ALLOCATED)) barf(&quot;firstvals_nophys called on <span class="line-breaker"> <font color="red">+</font></span>non-ALLOCATED %p&quot;, x); PDL_Indx i, maxvals = PDLMIN(10, x-&gt;nvals); EXTEND(SP, maxvals); for(i=0; i&lt;maxvals; i++) { PDL_Anyval anyval = pdl_get_offs(x, i); if (anyval.type &lt; 0) barf(&quot;Error getting value, type=%d&quot;, anyval<span class="line-breaker"> <font color="red">+</font></span>.type); SV *sv = sv_newmortal(); ANYVAL_TO_SV(sv, anyval); PUSHs(sv); } </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11159421;displaytype=displaycode;part=2">&#91;download&#93;</a></div></pre> The problem was that the <tt class='inlinecode'>ANYVAL_TO_SV</tt> macro was, only for complex-valued data, calling a Perl function to create a Math::Complex object (well, a subclass thereof because the overloads were wrong). That obviously uses the top of the stack, including writing values into it, and reading values out of it, including mortal ones that then got freed because they were done with. Therefore, the function was returning with some garbage on the stack, but the last value was correct. <p>The solution was simply to do a <tt class='inlinecode'>PUTBACK</tt> after the <tt class='inlinecode'>PUSH</tt>, which moves the top of the stack above data we care about. The new text of the function with that: <pre class="code"><div class='codeblock'><tt class='codetext'>void firstvals_nophys(x) pdl *x PPCODE: if (!(x-&gt;state &amp; PDL_ALLOCATED)) barf(&quot;firstvals_nophys called on <span class="line-breaker"> <font color="red">+</font></span>non-ALLOCATED %p&quot;, x); PDL_Indx i, maxvals = PDLMIN(10, x-&gt;nvals); EXTEND(SP, maxvals); for(i=0; i&lt;maxvals; i++) { PDL_Anyval anyval = pdl_get_offs(x, i); if (anyval.type &lt; 0) barf(&quot;Error getting value, type=%d&quot;, anyval<span class="line-breaker"> <font color="red">+</font></span>.type); SV *sv = sv_newmortal(); ANYVAL_TO_SV(sv, anyval); PUSHs(sv); PUTBACK; } </tt></div><div class='embed-code-dl'><a href="?part=6;displaytype=displaycode;node_id=11159421;abspart=1">&#91;download&#93;</a></div></pre> The commit that fixed this is at <a href="https://github.com/PDLPorters/pdl/commit/68389413537c6ea7ed85f121a580b3b008ba82a6">https://github.com/PDLPorters/pdl/commit/68389413537c6ea7ed85f121a580b3b008ba82a6</a>. The docs on how to call a Perl function from C are at <a href="https://perldoc.perl.org/perlcall">https://perldoc.perl.org/perlcall</a>, with a full explanation of <tt class='inlinecode'>PUSHMARK</tt>, <tt class='inlinecode'>PUSH*</tt>, <tt class='inlinecode'>PUTBACK</tt>, and (after the call) <tt class='inlinecode'>SPAGAIN</tt>, and maybe <tt class='inlinecode'>POP*</tt> and maybe then <tt class='inlinecode'>PUTBACK</tt>.</ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159314" name="post-head-id11159314" href="?node_id=11159314" >Debugger issue solved (two years ago)</a> <br/> <!-- REPLIES --> 2 direct replies &mdash; <a href="?node_id=11159314">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=131279">talexb</a> <br/> <!-- DATE --> on May 06, 2024 at 20:57 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p>I upgraded a machine to the latest Ubuntu and got Perl 5.34.0, which included a problem with the debugger: <pre class="code"><div class='codeblock'><tt class='codetext'> DB&lt;4&gt; v <span class="line-breaker"> <font color="red">+</font></span> Undefined subr<span class="line-breaker"> <font color="red">+</font></span>outine &amp;DB::cmd_l called at /usr/share/perl/5.34/perl5db.pl line 6034<span class="line-breaker"> <font color="red">+</font></span>. at /usr/share/perl/5.34/perl5db.pl line 6034. <span class="line-breaker"> <font color="red">+</font></span> DB::cm<span class="line-breaker"> <font color="red">+</font></span>d_v(&quot;v&quot;, &quot;&quot;, 56) called at /usr/share/perl/5.34/perl5db.pl line 4798 DB::cmd_wrapper(&quot;v&quot;, &quot;&quot;, 56) called at /usr/share/perl/5.34/pe<span class="line-breaker"> <font color="red">+</font></span>rl5db.pl line 4311 DB::Ob<span class="line-breaker"> <font color="red">+</font></span>j::_handle_cmd_wrapper_commands(DB::Obj=HASH(0x55e85838c150)) called <span class="line-breaker"> <font color="red">+</font></span>at /usr/share/perl/5.34/perl5db.pl line 32 00 <span class="line-breaker"> <font color="red">+</font></span> DB::DB<span class="line-breaker"> <font color="red">+</font></span> called at report_warnings.pl line 56 Debugged program terminated. Use q to quit or R to restart, <span class="line-breaker"> <font color="red">+</font></span> use o inhibit_<span class="line-breaker"> <font color="red">+</font></span>exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB&lt;4&gt; </tt></div><div class='embed-code-dl'><a href="?abspart=1;node_id=11159314;displaytype=displaycode;part=1">&#91;download&#93;</a></div></pre> My friend Google brought me to <a href="https://groups.google.com/g/linux.debian.bugs.dist/c/-IDmr2-XW8g">this page</a> that had links to the necessary patch to <tt class='inlinecode'>perl5db.pl</tt> on github, bringing the script from version 1.60 to 1.60_01.</p> <p>And, of course, the patch worked just fine. What a great community. Thanks for the patch!</p> <p>PS: Ugh, sorry -- the problem was that the <tt class='inlinecode'>v</tt> command that I use a lot (Where am I? Oh, there I am!) crashed the debugger. The patch solves that problem.</p> <div class="pmsig"><div class="pmsig-131279"> <p>Alex / <a href="?node=talexb">talexb</a> / Toronto</p> <p><small>Thanks PJ. We owe you so much. <a href="http://www.groklaw.net">Groklaw</a> -- RIP -- 2003 to 2013.</small></p> </div></div></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> <!-- BEGIN embed node with vote container --> <!-- 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-id11159276" name="post-head-id11159276" href="?node_id=11159276" >The Virtue of Laziness</a> <br/> <!-- REPLIES --> 4 direct replies &mdash; <a href="?node_id=11159276">Read more / Contribute</a> </td> <td valign="top" align="right" style="padding-right:.2em"> <!-- AUTHOR --> by <a href="?node_id=1226468">jo37</a> <br/> <!-- DATE --> on May 04, 2024 at 17:57 </td> </tr> <tr class="post-voterep"> <td colspan="2" class="voterep"> </td> </tr> <tr class="post-body post_body"> <td colspan="2"> <ul><p> Dear Monks and Nuns,<br /><br /> lately I came across an issue with dereferencing array refs. It looks like there is some hidden "lazy deref" when an array ref is used in a <tt class='inlinecode'>foreach</tt> loop, compared to the usage as a sub argument. Consider these two subs that do nothing but <tt class='inlinecode'>die</tt>. The main difference is the array dereference as an argument to <tt class='inlinecode'>foreach</tt> or <tt class='inlinecode'>map</tt>. </p> <pre class="code"><div class='codeblock'><tt class='codetext'>use experimental &#39;signatures&#39;; sub map_die ($ar) { eval {map {die} @$ar}; } sub for_die ($ar) { eval { for (@$ar) { die; } } } </tt></div><div class='embed-code-dl'><a href="?node_id=11159276;part=5;displaytype=displaycode;abspart=1">&#91;download&#93;</a></div></pre> Benchmarking is amazing: <pre class="code"><div class='codeblock'><tt class='codetext'>use Benchmark &#39;cmpthese&#39;; my @arr = ((0) x 1e6); cmpthese(0, { map =&gt; sub {map_die(\@arr)}, for =&gt; sub {for_die(\@arr)}, }); __DATA__ Rate map for map 1257/s -- -100% for 1664823/s 132352% -- </tt></div><div class='embed-code-dl'><a href="?abspart=1;displaytype=displaycode;part=6;node_id=11159276">&#91;download&#93;</a></div></pre> <p> Then I remembered the "lazy generators" from <a href="https://metacpan.org/pod/List%3A%3AGen">List::Gen</a> and gave it a try. There is some progress, but it cannot come up to <tt class='inlinecode'>foreach</tt>. </p> <pre class="code"><div class='codeblock'><tt class='codetext'>use List::Gen &#39;array&#39;; sub gen_die ($ar) { eval { &amp;array($ar)-&gt;map(sub {die}); } } cmpthese(0, { map =&gt; sub {map_die(\@arr)}, for =&gt; sub {for_die(\@arr)}, gen =&gt; sub {gen_die(\@arr)}, }); __DATA__ Rate map gen for map 1316/s -- -93% -100% gen 18831/s 1330% -- -99% for 1662271/s 126174% 8727% -- </tt></div><div class='embed-code-dl'><a href="?part=8;displaytype=displaycode;node_id=11159276;abspart=1">&#91;download&#93;</a></div></pre> <p> Wouldn't it be nice to have some kind of "explicit lazy dereferencing" in Perl? </p> <p> <b>Update May 10, 2024:</b> Added the <tt class='inlinecode'>signatures</tt> feature as suggested by <a href="?node=Danny">Danny</a> in <a href="?node_id=11159296">Re: The Virtue of Laziness</a>. </p> <div class="pmsig"><div class="pmsig-1226468"> <p>Greetings,<br />&#128059;</p> <tt>$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$</tt> </div></div></ul> </td> </tr> <!-- End Post --> <!-- END embed node with vote container --> </table> </td> </tr> </table> <!-- END listapproved default outer container --> <table width="100%" class="highlight navbar" border="0" cellpadding="2" cellspacing="0"> <tr><td align="left" width="100"> &nbsp;</td><td align="center">(1-15) of 300</td><td align="right" width="100"> <a href="?node_id=480;next=15">Older&nbsp;entries</a>&gt;&nbsp;</td></tr></table> <div class='editnodetext'> <!--( perlmeditation, Add your Meditation, Meditation, , )--> <br /><table width='100%' class='addnewform'> <tr class='titlebar add-root-blurb'> <td><b><a name='post'> Add your Meditation </a></b></td></tr> <tr><td> <form method="post" action="?" enctype="multipart/form-data"> <span><input type="hidden" name="node_id" value="480" ></input></span> <input type="hidden" name="type" value="perlmeditation" /> <input type="hidden" name="lastnode_id" value="480" /> <span class='add-title'>Title:</span> <input type="text" name="node" /> <br /><span class='add-text'>Meditation:</span><br/> Use:&nbsp; <tt>&lt;p&gt; text here (a <b>p</b>aragraph) &lt;/p&gt;</tt> <br />and:&nbsp; <tt>&lt;code&gt; code here &lt;/code&gt;</tt><br /> to format your post, it's "<a href="?node_id=674668">PerlMonks-approved HTML</a>": <br /> <textarea name="perlmeditation_doctext" rows="10" cols="60"></textarea> <br /> <input type="submit" name="op" value="preview" /> </form> </td></tr></table> </div> <hr /> <li> Posts are HTML formatted. <b>Put <tt class='inlinecode'>&lt;p&gt; &lt;/p&gt;</tt> tags around your paragraphs. Put <tt class='inlinecode'>&lt;code&gt; &lt;/code&gt;</tt> tags around your code and data!</b> </li> <li> <small>Titles consisting of a single word are discouraged, and in most cases are disallowed outright.</small> </li> <li><small> Read <a href="?node_id=237057">Where should I post X?</a> if you're not absolutely sure you're posting in the right place. </small></li> <li><small> Please read these before you post! &mdash;<ul> <li><a href="?node_id=341118">How do I compose an effective node title?</a></li> <li><a href="?node_id=174051">How do I post a question effectively?</a></li> <li><a href="?node_id=674668">Markup in the Monastery</a></li> </ul> </small></li> <li><small> Posts may use any of the <a href="?node_id=29281">Perl Monks Approved HTML tags</a>: <dl><dd>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</dd></dl> </small></li> <!--&general&--> <!-- <li><small> <strong>Snippets of code</strong> or other preformatted text should be wrapped in <strong>&lt;code&gt;</strong> tags, <strong>not</strong> <tt>&lt;pre&gt;</tt> tags. In fact, <tt>&lt;pre&gt;</tt> tags should almost never be used. </small></li> --> <li><small> You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.) </small> <table cellpadding=0 cellspacing=0 border=0 > <tr> <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td><small> <u>For:</u> </small></td> <td>&nbsp;&nbsp;&nbsp;</td> <td><small> <u>Use:</u> </small></td> </tr> <tr><td></td><td><small> &amp; </small></td><td></td><td> <tt>&amp;amp;</tt> </td></tr> <tr><td></td><td><small> &lt; </small></td><td></td><td> <tt>&amp;lt;</tt> </td></tr> <tr><td></td><td><small> &gt; </small></td><td></td><td> <tt>&amp;gt;</tt> </td></tr> <tr><td></td><td><small> &#91; </small></td><td></td><td> <tt>&amp;#91;</tt> </td></tr> <tr><td></td><td><small> &#93; </small></td><td></td><td> <tt>&amp;#93;</tt> </td></tr> </table> </li> <li><small>Link using PerlMonks shortcuts! <a href="?node_id=43037">What shortcuts can I use for linking?</a></small></li> <li><small> See <a href="?node_id=17558">Writeup Formatting Tips</a> and other pages linked from there for more info. </small></li> <!-- args=(showhints sitedoclet -approvedlist 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) NODE.title = Meditations NODE.owner = 485628 N.title = showhints sitedoclet N.owner = 17342 --> <!-- 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" 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="480" ></input></span> <input type="hidden" name="op" value="login" /> <input type="hidden" name="lastnode_id" value="480" /> <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=480">www</a>.<a class='domainlink' href="http://perlmonks.com/index.pl?node_id=480">com</a> | <a class='wwwdomainlink' href="http://www.perlmonks.net/index.pl?node_id=480">www</a>.<a class='domainlink' href="http://perlmonks.net/index.pl?node_id=480">net</a> | <span class='currentdomain'>www</span>.<a class='domainlink' href="http://perlmonks.org/index.pl?node_id=480">org</a></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" 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="480" ></input></span><i class="cb_quiet">and all is quiet...</i><br /> <input type="submit" name="foo" value="Refresh" /> </form> <i><br /> <a href="?node=ChatterBox%20FAQ">How do I use this?</a> &bull; <a href="?node=last%20hour%20of%20cb">Last hour</a> &bull; <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" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <span class="other-users-text">Others <span class="other-users-blurb">studying</span> the Monastery:</span> (3)<br /><ul class="spacey-list"><li><span class='even-row'><span class='item-000'><span class='user-level-26'><span class='user-461912'><a title="GrandFather's home node. Level 26. Member of: janitors" href="?node_id=461912">GrandFather</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 2024-11-24 13:51 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" 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&amp;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 = Meditations 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" 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 = Meditations 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" 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 = Meditations 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" 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 = Meditations 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" class="nodelethead-annot"><sup>?</sup></a> </th></tr> <tr><td class="nodelet_body"> <div class="poll-vote-form"><b>chatterbot is...</b><form method="post" action="?" enctype="multipart/form-data"> <span><input type="hidden" name="displaytype" value="display" ></input></span><span><input type="hidden" name="node_id" value="11162559" ></input></span><p><label><input type="radio" name="vote" value="0" />Great! It updates <a href="?node_id=596792">last hour of cb</a> and helps me join a discussion </label><br /><label><input type="radio" name="vote" value="1" />The! Worst! Thing! Ever! It always ignores my self-upvotes for <a href="?node_id=11155739">cb stats</a>!!?! </label><br /><label><input type="radio" name="vote" value="2" />Somewhat useful in settling debates with coin flips and dice rolls </label><br /><label><input type="radio" name="vote" value="3" /><a href="?node=Chatterbot">Chatterbot</a>? Nobody told me about it! </label><br /><label><input type="radio" name="vote" value="4" />Not my cup of tea. I do not do that live chat thingie...</label><br /><input type="submit" value="Vote" /></p></form><p><a href="?node_id=11162559">Results (48 votes)</a>. Check out <a href="?node=past%20polls">past polls</a>.</p></div> </td></tr> </tbody> </table> <!-- End nodelets --> </td> <!--/nodelet handling code (monktainer)--> </tr> </table> </center> <!-- End main (monktainer)--> <br /> <br /> <div id="footer"> PerlMonks graciously bestowed by <a href="?node=vroom">Tim Vroom</a>.<br/> PerlMonks was recently assimilated by <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>

Pages: 1 2 3 4 5 6 7 8 9 10