Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

The Monastery Gates

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


erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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

Wall of Larry Quest
Starts at: Feb 26, 2024 at 05:00
Ends at: Dec 31, 2024 at 04:59
Current Status: Active
2 replies by jdporter

    By now you've all seen The St. Larry Wall Shrine. Well, it could use a fresh coat of gold leaf and shellac. Therefore, we are soliciting Larry-related items to be placed on the shrine. Links to offsite content are good; or if you have small bits of content, such as quotes, you'd like to contribute, that's fine too. Please reply to this Quest with your humble offerings. Thank you! And may St. Larry bless your codings and your debuggings.

poll ideas quest 2024
Starts at: Jan 01, 2024 at 00:00
Ends at: Dec 31, 2024 at 23:59
Current Status: Active
3 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
5.40 released
on Jun 10, 2024 at 04:35
5 replies by hippo
List::Gen revivified
on May 17, 2024 at 16:02
1 reply by jo37

    After more than ten years of hibernation I was able to waken List::Gen and fix some tests that failed since v5.19 including "fails on bleadperl" and a reported bug "primes incorrect for 664580, and slow".

    The new version is currently available on my github repo only, as the author is not responding. Does anybody have information about "Eric Strom" aka "ASG"? Otherwise I might try to get an indexing permission on CPAN as a co-maintainer, though I'm clueless regarding this process.


Requiring a version
4 direct replies — Read more / Contribute
by choroba
on Jun 18, 2024 at 04:45
    I noticed weird CPAN testers' failures in the last release of Syntax::Construct (5.38.2 without threads on Solaris, 5.38.2 threaded on Solaris, 5.38.0 threaded on Solaris).

    To know more, I released a dev version with a debugging output. It hasn't been tested on the same machines yet, but I've got similar results from 5.38.2 on FreeBSD and 5.38.0 on Linux. It seems that in all these cases, the following line doesn't fail:

    require (0 + 5.040); # Should fail in 5.38.X!

    I contacted the testers, but there has been digital silence so far.

    If you have a 5.38.X installed, would you be so kind and test it for me, too?

    I still fear it's my fault, so here's the line that shows the debugging information. Do you have any ideas?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Text::ExtractWords exhibits incomprehensible behavior?
3 direct replies — Read more / Contribute
by ibm1620
on Jun 15, 2024 at 11:42
    Hello, Monks,

    I'm looking for a module to extract words from a stream of text. I installed Text::ExtractWords and tried it:

    #!/usr/bin/env perl use v5.38; use Text::ExtractWords qw(words_list); say $^V; my $text = "12/21/84 Bob's 21st b'day was a wine-and-dine."; say $text; my @list; words_list(\@list, $text, {minwordlen => 2, maxwordlen => 26 }); say "Found words: " . join ' ', map {"[$_]"} @list; say $text;
    v5.38.2 12/21/84 Bob's 21st b'day was a wine-and-dine. Found words: [12] [21] [84] [bob's] [21st] [b'day] [was] [a] [wine-and +-dine] 122184bob's21stb'daywasawine-and-dine
    Note the output value of $text after call. How is it possible for any subroutine to modify a parameter, since I don't pass in a reference?

    Moreover, I looked at and it's all basically boilerplate except maybe for one line, which I don't understand:

    bootstrap Text::ExtractWords $VERSION;
    I feel like I'm missing something obvious here...

    Update: I'm not able to step into words_list() using the debugger! It just proceeds to my next source line.

    Update2: I even tried making a copy of $text (my $copy = $text) and passing $copy to words_list(), and afterwards *both* $copy and $text were munged. As Danny mentions below, this is XS code.

catch "use Inline::C" death
3 direct replies — Read more / Contribute
by bliako
on Jun 14, 2024 at 05:36

    I have a test which must fail as it tests passing bogus CFLAGS to Inline::C. e.g.

    use Inline C => Config => ccflagsex => '-test-bliako-A', ; ... use Inline C => <<'EOC'; #include <stdio.h> ... EOC

    The problem is that passing bogus CFLAGS to use Inline C => Config ... dies and my test fails without getting the chance to recognise that actually the test was passed as the die was expected.

    I tried to enclose said codeblock in eval { }; but I see no difference. Test fails.

    I find Inline::C using the use Inline C ... impractical and unecessary (perhaps it comes from Inline). So, is there a way to separate use Inline C; from its Config and Code sections? Ideally:

    use Inline C; Inline::C::config(...); Inline::C::embed_C_code(... c code ...);

    Alternatively, how can I catch the croak's and die's from when use'ing a module with Test::More.

    Or perhaps using require ... ?

    ps. I also tried to enclose it in a try{}catch{}; with same result: death

    bw, bliako

Compile perl with custom compiler path, perlbrew solution preferred
1 direct reply — Read more / Contribute
by bliako
on Jun 13, 2024 at 11:05

    Dear Monkees!

    I need to compile perl from source with custom compiler living in /usr/local/gcc82 (with subdirs bin, include, lib etc.). The reason is that I am embedding CUDA code (which is C) via Inline::C which needs this specific compiler. And XS code must be compiled with same compiler as its perl. (Indeed I get segmentation fault when doing otherwise). So I need perl compiled with this specific compiler and I am doing this on Linux.

    I prefer to let perlbrew do the compilation and installation. Is there a simple way to do it? Alternatively, I need to do it manually.

SOLVED: Get a list attributes from a given tag in Mojo::DOM
1 direct reply — Read more / Contribute
by igoryonya
on Jun 13, 2024 at 06:31
    I am learning a Mojo::UserAgent module and I've stumbled upon an issue, that I can't find an answer to on the internet and Mojo's mans.

    Here is the test code:

    #!/usr/bin/env perl use utf8; use feature 'say'; use Mojo::UserAgent; my $data = undef; #Get correct file my $cache = shift // '/tmp/cache.html'; if(-d $cache){ die("'$cache' is folder. You need to use file."); } if(-e $cache){ $data = Mojo::File->new($cache)->slurp; }else{ say 'Fetching fresh HTML'; my $ua = Mojo::UserAgent->new; my $tx = $ua->get(''); die "Could not fetch! Error is ", $tx->result->code unless($tx->re +sult->is_success); $tx->result->content->asset->move_to($cache); $data = $tx->result->body; #->body is not only <body>...</body> +, but a complete loaded resource content for 1 file. } say "Tags are:\n\t", Mojo::DOM->new($data)->find('a')->map(attr=>'href +')->uniq->sort->join("\n\t");
    It works, but, is there a way to list the existing attributes from a given tag?
    I tried to find it out from Mojo:
    and I didn't find any mentioning of attr enumeration or conversion to string.
    Is there a way to find out what tags exist on found tag?

    Something like this, probably?:

    I tried to enumerate with:
    my %attrs = "Tags are:\n\t", Mojo::DOM->new($data)->attr; map{ print "(%s)/(%s)\n", $_, $attrs{$_} } sort keys %attrs;
    But I only got empty hash.


    OK, i've figured it out:
    my $dom = Mojo::DOM->new($data); map{ say } $dom->find('a')->first; my $attrs = $dom->find('a')->first->attr; map{ printf "(%s)/(%s)\n", $_, $attrs->{$_} } sort keys %$attrs;
Defined test creates non-empty hash value
2 direct replies — Read more / Contribute
by glendeni
on Jun 12, 2024 at 12:34

    I'd always assumed tests could never _create_ anything - they were just tests that either succeeded or failed, never actually affecting variables solely by being used. So was very surprised to recently find that use of the 'defined' test on a hash of arrays ala

    defined $hash{$name}[$integer]

    actually _created_ an empty $hash{$name} if $hash{$name} is non-existent, so is thereafter not non-existent.

    Example code:

    my %hash = ( "A" => [ 1,2 ] ) ; if ( exists $hash{"B"} ) { say "This will NOT print" ; } if ( defined $hash{"B"}[1] ) { say "This will NOT print" ; } if ( exists $hash{"B"} ) { say "This WILL print" ; }

    So the "correct" test for existence of an array element in a hash of arrays should be

    if ( exists $hash{"B"} && defined $hash{"B"}[1] )

    Would appreciate comments by those with deeper knowledge of perl than I, since I can't see how such creation is in any way beneficial - rather it can introduce problems into a script, since the first use of such a test will fail but a second same test will later succeed without the programmer intending (or expecting) any such change.

    IMHO a test should succed, or fail, or throw an error - period.

    FYI the same occurs for a test ala "$#{$hash{"B"}} > -1".

    Background: Have used perl regularly since 1998 so am experienced in perl, but never dug too deeply into it.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-06-18 12:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.