Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

The Monastery Gates

( [id://131]=superdoc: print w/replies, xml ) Need Help??

New here?I want to ask a question of the Perl Monks. Where do I start?

Notices:

hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.

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

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

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

Perl News
Linuxlinks on Perl Static Site Generators
on Feb 20, 2026 at 05:14
0 replies by mldvx4
Perl mentioned at The New Stack
on Feb 13, 2026 at 06:02
3 replies by mldvx4

    The New Stack has mentioned Perl in the context of TIOBE:

    On the scripting side, Perl has also returned to prominence. Once the undisputed leader in scripting, Perl declined after years of internal fragmentation and competition from newer languages, writes Paul Jansen, CEO of TIOBE in the post. “Recently, however, it has staged a comeback, reclaiming a position in the TIOBE top 10 since January 2018,” he writes.

    Perl is actually number 11 on the index right now. It was ranked 30th at the same time last year.

    “It’s hard to judge a programming language’s popularity based on some of the indexes,” Andrew Cornwall, an analyst at Forrester Research, tells The New Stack.

    Statistical language R is making a comeback against Python.

    As we know these rankings are quite arbitrary and the methodology is more than flawed due the selection of repositories surveyed and the ones which get ignored. However, MSFT's long-runnning smear campaign against Perl is losing steam.

Supplications
A little overloading conundrum
2 direct replies — Read more / Contribute
by syphilis
on Mar 06, 2026 at 19:46
    Hi,

    I have a module A that overloads the '-' operator via its A::oload_minus() subroutine.
    And I have a second module B that also overloads the '-' operator via it's own B::oload_minus() subroutine.
    Both modules also have their own oload_add, oload_mul, oload_div, oload_mod and oload_pow subroutines that overload the other basic arithmetic operators).

    I have constructed the overloading in module A to handle B objects.
    But if module B's overloading subroutines are passed a module A object, it is (by my current design) a fatal error.
    use A; use B; $A_obj = A->new(16); $B_obj = B->new(6); my $n1 = $A_obj - $B_obj; # $n1 is an A object with value 10 my $n2 = $B_obj - $A_obj; # Fatal error
    In the above demo I want $n2 to be an A object, with the value of -10.
    That is, I want the A::oload_minus() sub to receive the args ($A_obj, $B_obj, TRUE).
    Instead, the B::oload_minus() sub is receiving the args ($B_obj, $A_obj, FALSE) - which is, by my current design, a fatal error since B::overload_minus() does not currently accept A objects.

    Is there a way that I can work around this without making any changes to the B module ? (The motivation to not alter module B is simply that I don't want to add more clutter to B unless I need to.)

    My module "A" is in fact Math::MPC, and my module "B" is in fact Math::MPFR.

    AFTERTHOUGHT: I should point out that the arithmetic overloading in the publicly available versions of Math::MPC don't yet accept Math::MPFR objects. (I've currently implemented this new feature on my local Math::MPC builds only.)

    Cheers,
    Rob
Type coercion and union
1 direct reply — Read more / Contribute
by tomred
on Mar 06, 2026 at 12:29

    I have the following Type defined.

    package Types; use v5.34; use warnings; use Type::Utils qw( as coerce declare from via ); use Types::Common qw( Enum Str ); use Type::Library -base, -declare => qw( CreditType InvoiceType ); declare InvoiceType, as Enum [qw/ ACCPAY ACCREC /]; coerce InvoiceType, from Str, via { #warn "Trying to coerce $_\n"; my %types = ( Invoice => 'ACCREC', SupplierInvoice => 'ACCPAY', ); #my $ret = $types{$_}; #warn "Returning $ret\n"; return $types{$_}; } ; declare CreditType, as Enum [qw/ ACCPAYCREDIT ACCRECCREDIT /]; coerce CreditType, from Str, via { warn "Trying to coerce $_\n"; my %types = ( Credit => 'ACCRECCREDIT', SupplierCredit => 'ACCPAYCREDIT', ); my $ret = $types{$_}; warn "Returning $ret\n"; return $types{$_}; } ; 1;

    I have a class that uses the types as a union, this or that

    package MyApp; use v5.34; use warnings; use Moo; use Types qw/ InvoiceType CreditType /; has 'type' => ( is => 'ro', isa => InvoiceType | CreditType, required => 1, coerce => 1, ); sub run { my ($self) = @_; say "Running with ".$self->type; } 1;

    I have a test to make sure it's doing what I expect `t/type.t`

    #!/opt/perl5/bin/perl use v5.34; use warnings; use Test::More; use Types qw( InvoiceType CreditType ); { subtest 'Type coercion' => sub { is InvoiceType->coerce('Invoice'), 'ACCREC', 'Can coerce a sales invoice'; is InvoiceType->coerce('SupplierInvoice'), 'ACCPAY', 'Can coerce a supplier invoice'; is CreditType->coerce('Credit'), 'ACCRECCREDIT', 'Can coerce a credit type'; is CreditType->coerce('SupplierCredit'), 'ACCPAYCREDIT', 'Can coerce a supplier credit type'; }; } { my $class = 'MyApp'; use_ok($class); subtest 'Class coercion' => sub { for my $t ( qw/Invoice SupplierInvoice Credit SupplierCredit / + ) { note "Type=$t"; my $x = new_ok($class => [ type => $t ]); note "Now Type=".$x->type; } }; } done_testing;
    t/type.t .. # Subtest: Type coercion ok 1 - Can coerce a sales invoice ok 2 - Can coerce a supplier invoice ok 3 - Can coerce a credit type ok 4 - Can coerce a supplier credit type 1..4 ok 1 - Type coercion ok 2 - use MyApp; # Subtest: Class coercion # Type=Invoice ok 1 - An object of class 'MyApp' isa 'MyApp' # Type=SupplierInvoice ok 2 - An object of class 'MyApp' isa 'MyApp' # Type=Credit not ok 3 - MyApp->new() died # Failed test 'MyApp->new() died' # at t/type.t line 31. # Error was: Undef did not pass type constraint "InvoiceType| +CreditType" (in $args->{"type"}) at /home/dpaikkos/spl/local/lib/perl +5/Test/More.pm line 741 # "InvoiceType|CreditType" requires that the value pass "Credi +tType" or "InvoiceType" # Undef did not pass type constraint "InvoiceType" # "InvoiceType" is a subtype of "Enum["ACCPAY","ACCREC"]" # "Enum["ACCPAY","ACCREC"]" requires that the value is def +ined # Undef did not pass type constraint "CreditType"

    I excel at leaving typos in my code but I am pretty sure there are none in the code so far. The coercions appear to work in a stand alone fashion but when used as a union, the 2nd Type does not appear to apply the coercion. If I swap the "CreditType" to be the first item, I find that the InvoiceType fails.

    I suspect I could use some kind of named parameterized coercion and `plus_coercions` but I hit this snag and haven't been able to move forward.

    Does anyone have any insights into what I'm doing wrong?

    Thanks in advance
WebPerl in a Progressive Web App?
1 direct reply — Read more / Contribute
by LanX
on Mar 06, 2026 at 08:52
    Hi

    Is it possible to run WebPerl inside a PWA?

    Hence effectively running Perl inside an app which can be installed on Android, Win, Linux?

    Has it been attempted yet?

    What are the results?

    Does it reduce the startup time of Perl because it's running hot in the background?

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

Tieing STDERR to a textbox causes the IPC::Run start function to fail
2 direct replies — Read more / Contribute
by CrashBlossom
on Mar 05, 2026 at 20:28
    Greetings Monks, I am running strawberry perl 5.30 under windows 11.

    When the program below reaches the start function, it fails with the seemingly nonsensical error "Can't locate auto/Tk/ROText/FILENO.al". Tieing only STDOUT to the same widget is no problem.

    Does anyone have any insight as to what is happening here?

    use warnings; use strict; use IPC::Run qw(start pump finish timeout); use Tk; require Tk::ROText; my $mw = MainWindow->new(-title => " NON BLOCKING"); my $outw = $mw->Scrolled('ROText', -font => "{Courier New} 10 bold", -background => 'DarkBlue', -foreground => 'OldLace', -scrollbars => 'se', -wrap => 'none', -width => 100, -height => 10, )->pack(-fill => "both", -expand => 1); + # tie *STDOUT, 'Tk::Text', $outw; tie *STDERR, 'Tk::Text', $outw; my ($in, $out, $err) = ('', '', ''); my $h; if (! defined(eval { $h = start ['cmd.exe', '/c', 'dir'], \$in, \$out, + \$err; })) { print "\nStart failed: $@\n"; } while($h->pumpable) { $h->pump; print $out; $out = ''; } $h->finish; MainLoop;
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2026-03-11 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.