If you're new here please read PerlMonks FAQ and Create a new user.
Quests
|
Monk Quips Quest
Starts at: May 01, 2023 at 08:00
Ends at: Dec 31, 2023 at 18:59
Current Status: Active
|
5 replies
|
by erzuuli
|
Esteemed Monk kcott has recently proposed an excellent idea.
heretoforthwithstanding, we invite all monks to submit ideas for new monk quips!
Your quip suggestion should include the following details:
- Intended quip location: either XP Nodelet, Chatterbox, or Monkbar (that's the page header).
- Text of quip.
- Optional: background & foreground colours. If you include these, be sure they are nicely contrasting.
.
|
poll ideas quest 2023
Starts at: Jan 01, 2023 at 00:00
Ends at: Dec 31, 2023 at 23:59
Current Status: Active
|
2 replies
|
by pollsters
|
|
|
Perl News
|
TPRC 2023 in Toronto / Room block closes June 19
on Jun 02, 2023 at 10:05
|
0 replies
|
by talexb
|
Howdy! We have a full three day conference planned in Toronto, running July 11-13 -- that's just 4 1/2 weeks away!
If you haven't registered and grabbed a room yet, this is a reminder that our room block will disappear on Monday, June 19, so be sure to grab the room you want before that date.
In addition to the conference, there's going to be a hackathon on Monday, July 10, and Dave Rolsky will be putting on a one-day Go class on Friday July 14. That's all taking place at the venue, the Doubletree Hilton on Chestnut, in downtown Toronto. Please visit the conference website for more information, and I hope to see LOTS of you there!
Alex / talexb / Toronto
Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.
|
Raku is one of the few newbies in the top 100
on May 25, 2023 at 02:25
|
2 replies
|
by reisinge
|
"The only languages younger than 10 years in the current top 100 are: Swift (#14), Rust (#17), Crystal (#48), Solidity (#59), Pony (#71), Raku (#72), Zig (#88) and Hack (#92). None of them are less than 5 years old. In other words, it is almost impossible to hit the charts as a newbie. On the contrary, we see that golden oldies revive. Take for instance Fortran, which is back in the top 20 thanks to the growing demand for numerical computational power. So, if you have just invented a brand new language, please have some patience!" -- Paul Jansen CEO TIOBE Software
|
|
Supplications
|
What is ignore.txt
2 direct replies — Read more / Contribute
|
by Bod
on Jun 08, 2023 at 13:47
|
|
I am trying to 'properly' build AI::Embedding and publish the next development version to CPAN. So, as kcott suggested, I have turned on RELEASE_TESTING and I am running the tests using prove. My user tests are now passing but I am stuck on the author tests.
Attempting to prove -vb t/manifest.t I get the following error:
not ok 1# The following files are not named in the MANIFEST file: C:\U
+sers\user\Perl\AI-Embedding\AI-Embedding\ignore.txt, C:\Users\user\Pe
+rl\AI-Embedding\AI-Embedding\t\01-openai.t, C:\Users\user\Perl\AI-Emb
+edding\AI-Embedding\xt\boilerplate.t
All these files were created by Module::Starter.
What is ignore.txt used for and does it need to be added to the manifest file?
What is a xt directory for? Can I ignore or delete it?
For slightly later, once I've built the module, should I delete the blib directory before make dist?
Also, because I have AI::Embedding v0.1_1 installed, I had to add use lib 'lib'; to the test files to make the tests use the right version of the module. Will this create difficulties if it is left in when the module gets uploaded to CPAN?
|
How to determine if 'strict' is enabled
1 direct reply — Read more / Contribute
|
by kcott
on Jun 06, 2023 at 21:59
|
|
Background
I'm doing some testing of Perl::Dist::APPerl on various platforms.
I have a test script which currently checks that 'use v5.36;' enables the warnings pragma
and features are enabled or disabled as appropriate.
Question
I'm looking for a platform-independent way to determine if the strict pragma is in effect without forcing an abort.
If strict is specifically used, it can be determined from %INC:
ken@titan ~/tmp
$ perl -e 'use strict; print "$_\n" for keys %INC;'
strict.pm
ken@titan ~/tmp
$ perl -e 'use strict; my $x = xyz;'
Bareword "xyz" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
However, if strict is enabled automatically via use VERSION (where VERSION >= 5.12),
this method doesn't work:
ken@titan ~/tmp
$ perl -e 'use 5.012; print "$_\n" for keys %INC;'
ken@titan ~/tmp
$ perl -e 'use 5.012; my $x = xyz;'
Bareword "xyz" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
Any help with this would be appreciated. Thankyou.
|
Are there CPAN modules that can help write realtime software catalogs
3 direct replies — Read more / Contribute
|
by misterperl
on Jun 06, 2023 at 14:42
|
|
We have several thousand pm, pl, or cgi files in one mega directory. Pareto suggests that probably only twenty percent or so are used, or get frequent use. But we don't know. It would be useful to know. My idea is to have a code repository, and an active code dir. If a file is needed, it can be pulled from the repository.
A smaller set of files would be much easier to manage in the active dir. Especially for newbies.
I'm thinking of an SQL table with one row per file access, and the access type like edited the file, ran the file, "required" or "used" the file, chmodded, etc. Maybe once a day, code could run that reads access info for each file, and moves them to or from the active code directory depending on when they were last used. Or maybe based on frequency of use, rather than last use.
So I'm wondering are there CPAN modules to assist with this? I can have the repository as part of @INC, and as files are used, a mysql row is added. Starting with 100% in the repository, after weeks of running, source files we need would be in active. The rest would be inactive and maybe even after a long term, removed. And since it sounds like this table has a potential to get large, we might have to cull old rows. A thousand files invoked a thousand times a month could be a BIG table!
I'm thinking modules that I could add to the top of every sourcefile, that signals a write to the access table. And maybe modules that help me tell what classes (pms) are actually invoked or resourced, rather than just "used" , with no real use. Or, a CPAN module that can generate an array of all use or required files in the hierarchy under the initial pl or cgi.
I'm pretty sure I can write all the functionality from scratch, but if CPAN modules exist that facilitate this function, I'm all-in. I guess in-summary I want like a meta library that tells me a bunch of things about what is running, what it's using, where it came from, maybe how many milliseconds it ran, what user ran it, etc etc.. I see potential concurrency issues with a running program that has one of it's "pm's" moved mid-run; not sure how to deal with that since we operate 24x7. And other concerns. I'm still in the dreaming stage..
Best Regards Monks!
|
Multidimensional arrays
5 direct replies — Read more / Contribute
|
by Bod
on Jun 06, 2023 at 10:55
|
|
We operate a few sites with subscriptions. Until recently, the subscription cost has been fixed with just three plan options - monthly, 6 monthly or annually. However, we now want to increase the cost on one site for new members but not existing members. Existing members will have their current subscription rate locked for life.
Currently, the three subscription rates are declared in a parameters file:
our $stripe_price_1 = 'price_123245';
our $stripe_price_6 = 'price_123267';
our $stripe_price_12 = 'price_123289';
The price code is passed to Stripe during the checkout process.
Having multiple prices in the future means we need to adopt a different approach. Users have the option to change between payment plans so they can swap from monthly or annually, etc. Therefore, we need to know which pricing level they are on as well as the plan. We can (and currently do) easily get the plan from Stripe. But getting the level is more tricky. We'd have to get the price code and work backwards.
So, I am thinking of adding two fields to the Subscription table of the database - priceLevel and pricePlan - and replacing the above declarations with a two dimensional Perl array of hashref:
my @price;
$price[1,1] = {
'name' => 'Early Adopter',
'plan' => 1,
'length' => 1,
'price' => 3.49,
'stripe' => 'price_123245',
};
$price[1,6] = {
'name' => 'Early Adopter',
'plan' => 1,
'length' => 6,
'price' => 18.99,
'stripe' => 'price_123267',
};
$price[1,12] = {
'name' => 'Early Adopter',
'plan' => 1,
'length' => 12,
'price' => 32.49,
'stripe' => 'price_123289',
};
$price[2,1] = {
'name' => 'First Increase',
'plan' => 2,
'length' => 1,
'price' => 3.99,
'stripe' => 'price_123445',
};
$price[2,6] = {
...
};
$price[2,12] = {
'name' => 'First Increase',
'plan' => 2,
'length' => 12,
'price' => 33.99,
'stripe' => 'price_123489',
};
$price[3,1] = {
...
};
$price[3,6] = {
...
};
$price[3,12] = {
...
};
The two dimensions of the array corresponding to the two newly added database fields.
I have two doubts about this approach...
- There are lots of 'spaces' in the array
- I seem to recall reading (probably) in The Monastry that multidimensional arrays are not a good idea
Any advice very welcome...
|
Image::Magick - Exception 435: unable to open file `Image::Magick::Q16' @ error/Q16.xs/XS_Image__Magick__Q16_Read/13529
4 direct replies — Read more / Contribute
|
by mldvx4
on Jun 06, 2023 at 08:17
|
|
An old script has begun giving trouble reading SVG files using Image::Magick, lately. Below is one example which shows this new kind of error. How would I go about figuring how to get past this?
Edit: I should add that the error arises on both Alpine Linux v3.12 and Linux Mint 21.1
#!/usr/bin/perl
use Image::Magick;
use strict;
use warnings;
my $image = Image::Magick->new;
open(IMAGE, \*DATA);
my $err = $image->Read(file=>\*IMAGE);
close(IMAGE);
if ($err) {
print "Error b: $err\n";
exit(1);
}
print qq(OK\n);
exit(0)
__DATA__
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 454.22 65.577"><p
+ath class="logotype-svg" style="text-align:start" d="M388.22 0c-3.287
+ 0-6.357.717-9.22 2.125a23.81 23.81 0 0 0-7.406 5.562c-2.066 2.348-3.
+686 5.043-4.906 8.094a26.399 26.399 0 0 0-1.782 9.565c0 3.192.592 6.3
+23 1.72 9.375 1.126 3.05 2.715 5.745 4.78 8.092 2.066 2.348 4.496 4.2
+33 7.313 5.688 2.86 1.455 6.024 2.187 9.5 2.187 3.284 0 6.337-.67 9.1
+54-2.03 2.817-1.41 5.278-3.263 7.344-5.563 2.11-2.347 3.73-5.043 4.90
+5-8.094a25.796 25.796 0 0 0 1.844-9.656c0-3.098-.562-6.152-1.69-9.157
+-1.125-3.05-2.715-5.762-4.78-8.156-2.02-2.392-4.48-4.324-7.344-5.78C3
+94.793.75 391.646 0 388.22 0zm48.124 0c-2.676 0-5.09.296-7.25.906-2.1
+13.564-3.95 1.452-5.5 2.625a11.83 11.83 0 0 0-3.53 4.22c-.8 1.644-1.1
+9 3.53-1.19 5.688 0 2.066.375 3.81 1.126 5.22.75 1.36 1.857 2.53 3.31
+3 3.468 1.502.892 3.293 1.64 5.406 2.25 2.157.563 4.634 1.077 7.404 1
+.594 2.863.562 5.356 1.185 7.47 1.842 2.11.658 3.856 1.468 5.217 2.40
+7 1.363.937 2.344 2.06 3 3.373.66 1.267 1 2.84 1 4.718 0 3.757-1.463
+6.56-4.374 8.44-2.863 1.83-6.774 2.75-11.75 2.75-3.802 0-7.214-.577-1
+0.218-1.75-2.96-1.175-5.685-3.09-8.22-5.72l-1.063.906c2.676 2.676 5.5
+6 4.67 8.657 5.938 3.145 1.22 6.744 1.812 10.78 1.812 5.493 0 9.778-1
+.06 12.876-3.218 3.145-2.16 4.72-5.292 4.72-9.376 0-2.207-.438-4.045-
+1.283-5.5s-2.06-2.67-3.656-3.657c-1.55-.985-3.434-1.81-5.687-2.468-2.
+254-.658-4.762-1.25-7.53-1.814-2.77-.563-5.17-1.124-7.19-1.687-1.97-.
+61-3.607-1.328-4.874-2.126-1.268-.845-2.203-1.858-2.814-3.032-.61-1.2
+2-.906-2.716-.906-4.5 0-1.83.297-3.482.908-4.937.61-1.454 1.59-2.685
+2.906-3.72 1.314-1.077 2.98-1.903 5-2.467 2.065-.563 4.51-.843 7.375-
+.843 2.955 0 5.51.39 7.623 1.187 2.16.8 4.216 2.28 6.187 4.44l.908-.9
+7c-1.972-2.16-4.138-3.702-6.532-4.594C442.31.466 439.536 0 436.344 0z
+M42.406.594V44.47c0 3.097 2.042 5.75 5.563 5.75h3.185l-.03-1.345c-.07
+ 0-1.162.03-3.063.03-2.747 0-4.22-2.394-4.22-4.436V.592h-1.437zm194.8
+44 0v44c0 3.38 2.933 5.625 6.313 5.625 3.872 0 4.335.07 4.406 0v-1.41
+h-4.408c-2.465 0-4.696-1.472-4.907-4.218V14.75h10.188v-1.406h-10.188V
+.594h-1.406zm150.97.812c3.097 0 5.964.655 8.592 1.97a22.113 22.113 0
+0 1 6.97 5.343c1.97 2.204 3.513 4.775 4.593 7.685a24.2 24.2 0 0 1 1.6
+88 8.938c0 2.957-.546 5.886-1.625 8.75A24.424 24.424 0 0 1 404 41.748
+c-1.878 2.252-4.184 4.09-6.906 5.5-2.676 1.36-5.636 2.03-8.875 2.03-3
+.194 0-6.108-.654-8.784-1.97a21.838 21.838 0 0 1-6.906-5.28 26.811 26
+.811 0 0 1-4.592-7.656 25.784 25.784 0 0 1-1.625-9.03c0-2.96.53-5.856
+ 1.562-8.72 1.08-2.863 2.575-5.434 4.5-7.688 1.925-2.253 4.23-4.044 6
+.906-5.406 2.725-1.407 5.7-2.124 8.94-2.124zm-74.314 1.28c-.803.05-1.
+614.26-2.312.658a4.932 4.932 0 0 0-2.25 2.812c-.242.802-.233 1.666-.1
+56 2.5.085.928.264 1.826.53 2.72.198.66.457 1.3.72 1.936-1.03.005-2.0
+65.028-3.094.032-.25.004-2.197.022-3.188.312-5.243 1.537-8.483 4.27-1
+0.97 9.125l.002-9.435h-1.407v36.53h1.41V26.782c.914-3.343 2.604-6.266
+ 5-8.405 2.393-2.14 5.485-3.484 9.217-3.625 1.15-.046 2.384-.047 3.56
+3-.063l16.374 35.187c-5.563 12.674-5.773 13.11-6.125 13.53-.495.494-1
+.06.75-3.315.75l-1.25-.03v1.406l1.25.032c2.606 0 4.015-.552 4.72-1.75
+l.5-.843 21.75-49.626h-1.563l-15.282 34.78-15.405-33.468c.745-.01 1.5
+1.037 2.25-.062.8-.107 1.56-.427 2.25-.844.724-.437 1.372-.976 1.875-
+1.656.7-.946 1.062-2.137 1.094-3.313.027-.997-.17-1.986-.625-2.874a5.
+954 5.954 0 0 0-1.47-1.813 6.049 6.049 0 0 0-2.626-1.282 5.79 5.79 0
+0 0-1.438-.125h-.03zm.438 1.158c.78.008 1.552.298 2.187.75.638.45 1.1
+48 1.087 1.5 1.78.44.862.646 1.85.565 2.813-.082.964-.43 1.895-1.063
+2.625a4.482 4.482 0 0 1-3.655 1.5h-1.813L311.47 12a13.191 13.191 0 0
+1-.783-2.625c-.175-.918-.31-1.88-.062-2.78.248-.904.888-1.64 1.688-2.
+126.613-.375 1.313-.635 2.03-.627zM212.688 12.75c-10.28 0-14.188 9.38
+8-14.188 16.78v20.345h1.406V29.53c0-7.674 4.19-15.374 12.78-15.374 8.
+592 0 12.75 7.7 12.75 15.375v20.346h1.408V29.53c0-7.392-3.876-16.78-1
+4.156-16.78zm-195.72.03C6.76 12.78.283 21.93 0 31.72c0 9.364 7.384 18
+.874 17.594 18.874 5.492 0 12.278-3.047 14.53-8.75h-1.53c-2.183 4.788
+-7.65 7.343-13 7.343-8.943 0-15.554-7.91-16.188-16.78h33.438v-.75c-.1
+4-10-7.172-18.876-17.875-18.876zm55.25 0c-10.21 0-16.686 9.15-16.968
+18.94 0 9.364 7.415 18.874 17.625 18.874 5.492 0 12.247-3.047 14.5-8.
+75h-1.5c-2.183 4.788-7.65 7.343-13 7.343-8.942 0-15.585-7.91-16.22-16
+.78h33.47v-.75c-.14-10-7.203-18.876-17.906-18.876zm37.813 0c-5.983 0-
+10.692 4.583-12.123 10.19-.7 2.738-.937 3.63-.937 26.905h1.405c0-20.4
+86.054-22.017.438-24.813.897-5.91 5.075-10.935 11.218-10.875 6.56 0 1
+2.87 4.226 12.5 15.47 0 2.993.096 8.145.096 11.968 0 4.284-.094 8.25-
+.094 8.25h1.407s.15-13.597 0-20.22c-.245-10.665 5.52-15.455 11.906-15
+.468 6.653.1 11.758 5.12 12.156 12.094.202 3.537.094 17.597.094 23.59
+6h1.406c0-23.335-.228-24.368-.72-26.844-1.046-5.278-6.27-10.25-12.936
+-10.25-6.934 0-11.96 5.04-12.438 10.626-.563-5.633-6.545-10.625-13.37
+5-10.625zm63.658 0c-10.21 0-16.687 9.15-16.968 18.94 0 9.364 7.414 18
+.874 17.624 18.874 5.492 0 12.247-3.047 14.5-8.75h-1.5c-2.183 4.788-7
+.65 7.343-13 7.343-8.943 0-15.585-7.91-16.22-16.78h33.47v-.75c-.14-10
+-7.204-18.876-17.906-18.876zm95.188 0c-4.506 0-8.854 2.177-12.656 4.7
+82l.842 1.125c4.084-2.886 8.292-4.5 11.813-4.5 7.253 0 11.97 5.193 11
+.97 12.657V31c-1.902-.704-6.266-2.03-12.25-2.03-6.338 0-15.064 2.52-1
+5.064 10.405 0 6.267 5.227 11.22 11.846 11.22 5.703 0 11.737-2.12 15.
+47-6.908v3.375c0 1.48.91 2.743 2.53 2.813h1.406V48.47h-1.405c-.775 0-
+.984-.563-1.125-1.408V26.844c0-7.887-4.573-14.063-13.375-14.063zM16.9
+7 14.188c9.364 0 15.77 7.307 16.405 16.813H1.405C1.83 22.975 7.322 14
+.19 16.97 14.19zm55.25 0c9.364 0 15.77 7.307 16.405 16.813h-31.97c.42
+4-8.026 5.917-16.812 15.564-16.812zm101.468 0c9.364 0 15.772 7.307 16
+.406 16.813h-31.97c.423-8.026 5.917-16.812 15.564-16.812zm94.906 16.1
+88c4.084 0 8.236.638 12.25 2.187v7.25c0 .845-.327 1.82-1.03 2.875-2.8
+88 4.507-9.088 6.5-14.44 6.5-5.42 0-10.437-3.897-10.437-9.812 0-6.83
+7.672-9 13.657-9z" fill="currentColor"/></svg>
|
access object values
4 direct replies — Read more / Contribute
|
by averlon
on Jun 05, 2023 at 05:43
|
|
Hi,
I am strugling to access the values of an object.
Net::DNS::Packet=HASH(0x560a2c51be98)
'additional' => ARRAY(0x560a2c643678)
empty array
'answer' => ARRAY(0x560a2c4ea600)
0 Net::DNS::RR::PTR=HASH(0x560a2c650780)
'class' => 1
'owner' => Net::DNS::DomainName1035=HASH(0x560a2c6504f8)
'label' => ARRAY(0x560a2c6506d8)
empty array
'origin' => Net::DNS::DomainName=HASH(0x560a2c6507b0)
'label' => ARRAY(0x560a2c650798)
0 20
1 171
2 191
3 185
4 'in-addr'
5 'arpa'
'ptrdname' => Net::DNS::DomainName1035=HASH(0x560a2c650960)
'label' => ARRAY(0x560a2c650948)
0 20
1 'bl'
2 'bot'
3 'semrush'
4 'com'
'rdlength' => 23
'ttl' => 273
'type' => 12
'authority' => ARRAY(0x560a2c63e350)
empty array
'count' => ARRAY(0x560a2c6503c0)
0 1
1 1
2 0
3 0
'id' => 31152
'question' => ARRAY(0x560a2c51c270)
0 Net::DNS::Question=HASH(0x560a2c6438e8)
'qclass' => 1
'qname' => Net::DNS::DomainName1035=HASH(0x560a2c63edd0)
'label' => ARRAY(0x560a2c650480)
0 20
1 171
2 191
3 185
4 'in-addr'
5 'arpa'
'qtype' => 12
'replyfrom' => '127.0.0.1'
'replysize' => 80
'status' => 33152
'xedns' => Net::DNS::RR::OPT=HASH(0x560a2c650a50)
'owner' => Net::DNS::DomainName1035=HASH(0x560a2c4c81c0)
'label' => ARRAY(0x560a2c4c8160)
empty array
'type' => 41
As you might imagine, I look for a way to grab answer-ptrdname-label.
I have tried:
@$obj{answer)
which at least gives me a part of the object. The same as the method $obj->answer().
But then I am stuck!
Help appreciated!
|
Testing scripts under Test::More (with Test::Script)
2 direct replies — Read more / Contribute
|
by bliako
on Jun 02, 2023 at 07:40
|
|
Dear Monks,
I need to test a perl script which offers CLI functionality for some module.
I have discovered Test::Script and its script_fails() which is great.
BUT, I have noticed that in its synopsis it uses Test2::V0 as its general testing framework, And internally it depends on Test2::API. Unfortunately, I started this module some time ago and used Test::More. And I would not be happy changing horses mid-stream, as they say.
My questions are:
- Is there an alternative to script_fails() but without a Test2 (or any other Test[0-9]+ except Test::More) dependency?
- Is Test2 compatible with Test::More (can I just replace use Test::More and get on with it?)
Test::Script's synopsis starts with:
use Test2::V0;
use Test::Script;
I guess I have to start my tests in the same way and declare a dependency on Test2::V0 as well?
many thanks,
bw, bliako
|
|
Meditations
|
Please review documentation of my AI::Embedding module
2 direct replies — Read more / Contribute
|
by Bod
on Jun 02, 2023 at 17:26
|
|
Could you please take a look at the documentation for my new module and let me know if it makes sense? I always find that I am too close to the module and know what everything is supposed to do. In short, I have the Curse of Knowledge!
Here is the documentation
Why is it you only find typos after publishing?
The second raw_embedding method should read test_embedding in both the heading and the sample code. I've corrected this error now.
Thank you greatly for helping me get this right...
Edit:
Changed title from "RFC - Documentation Review" to "Please review documentation of my AI::Embedding module" as considered by erzuuli
|
|
|
|