Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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?

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

Quests
poll ideas quest 2025
Starts at: Jan 01, 2025 at 00:00
Ends at: Dec 31, 2025 at 23:59
Current Status: Active
1 reply 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
CPANSec is now CNA!
on Feb 26, 2025 at 04:05
0 replies by Tux
PDL::Stats 0.854 released
on Feb 25, 2025 at 14:11
0 replies by etj
    Significant changes in recent times: Any problems, please let us know by opening a GitHub issue, joining the IRC channel (both linked on the PDL::Stats page) or emailing the pdl-general list.
Supplications
schwartzian transform problem - Solved
1 direct reply — Read more / Contribute
by Cristoforo
on Feb 27, 2025 at 14:37
    I wonder if someone could tell me why this code is not working. It is to sort the records from highest percent to lowest. (I edited the regexp in split) Found one error. the mao{$_[0]} should be map {$_->[0]} and the split needed a newline (\n) at the end of the pattern split(/(?<=workspace\/data)\n/, $s) Now, I'm getting the correct sorted output.
C:\Old_Data\perlp>perl try3.pl >>> prd1702 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 746G 3.1T 23% /wor +kspace/data >>> prd1703 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 687G 3.2T 18% /wor +kspace/data >>> prd1701 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 887G 3.0T 13% /wor +kspace/data
(Below, the code before fixes noted above)
#!/usr/bin/perl use strict; use warnings; use feature 'say'; #https://stackoverflow.com/questions/79472778/sorting-the-content-of-a +-file my $s = <<EOF; >>> prd1701 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 887G 3.0T 13% /wor +kspace/data >>> prd1702 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 746G 3.1T 23% /wor +kspace/data >>> prd1703 Filesystem Size Used Avail Use% Moun +ted on /workspace 3.9T 687G 3.2T 18% /wor +kspace/data EOF my @data = map {$_[0]} sort {$b->[1] <=> $a->[1]} map {[$_, /\s(\d+)%/]} split(/(?<=workspace\/data)/, $s);
It is printing error as:
C:\Old_Data\perlp>perl try3.pl Use of uninitialized value in numeric comparison (<=>) at try3.pl line + 23. Use of uninitialized value in numeric comparison (<=>) at try3.pl line + 23.
what should be in PERL5LIB after installing from source the 5.40.1 version on MacOS (am64)
1 direct reply — Read more / Contribute
by kwolcott
on Feb 21, 2025 at 23:28

    I'm really confused and frustrated about how to get my PERL5LIB environment variable set correctly.

    I'm on MacOS Sequoia, aarch64, running zsh, installed Perl 5.40.1 from source, into the /opt/perl_5.40.1 directory.

    I already have a Perl 5.38.2, also built from source, located in the /opt/perl directory.

    I have a MacPorts version of Perl installed (5.34.3). I removed an additional MacPorts Perl version 5.38.3 that I had installed recently.

    I was reading in the Programming Perl book about PERL5LIB...I don't understand the order of the paths that should be in the PERL5LIB.

    I've installed MANY Perl modules from CPAN using cpanm, specifying -L path respective to each version of Perl.

    I have a section in my ~/.zshrc for Perl that looks like this:

    I'm not using homebrew and I'm not using perlbrew.

    I was using Sidef (installing manually as a standalone executable, not as a Perl Module) for some while, then things went bonkers when I installed Perl 5.38.3 from MacPorts (I think). Now Sidef fails, and many Perl programs fail that require modules (some work, some fail).

./wagstaff_primes.pl Can't locate local/lib.pm in @INC (you may need to install the local:: +lib module) (@INC entries checked: /opt/perl_5.40.1/lib/site_perl/5.4 +0.1/darwin-2level /opt/perl_5.40.1/lib/site_perl/5.40.1 /opt/perl_5.4 +0.1/lib/5.40.1/darwin-2level /opt/perl_5.40.1/lib/5.40.1) at ./wagsta +ff_primes.pl line 4. BEGIN failed--compilation aborted at ./wagstaff_primes.pl line 4.

The aforementioned is a script from Rosetta Code.

find /opt/perl_5.40.1/lib -type f -name lib.pm /opt/perl_5.40.1/lib/5.40.1/darwin-2level/lib.pm /opt/perl_5.40.1/lib/lib/perl5/local/lib.pm
Existing module for PerlX::Maybe except for hash existence?
1 direct reply — Read more / Contribute
by Corion
on Feb 21, 2025 at 11:51

    I'm quite fond of using PerlX::Maybe to pass parameters to subroutines if they are there:

GetOptions( 'f' => \my $filename, 'bar' => \my $bar, 'bruce' => \my $batman, 'u' => \my $universe, ); foo( file => $filename, maybe bar => $bar, maybe baz => $batman, maybe universe => $universe, )

The above will invoke foo() with only the hash keys that have a defined value. This is better in the sense that this allows foo() to make a difference between parameter was not passed at all and parameter was passed, but was undef:

sub foo( %options ) { if( ! exists $options{ baz } ) { $options{ baz } = 'Superman'; }; ... }

Now, I'd like to have something similar(ish) to maybe on the receiving side for subroutines and objects, but I'm lacking a good name and a good syntax for it. The idea is to only set a value in a hash if the key does not exist yet. This is different from the // operator, because that one only checks for defined-ness, not for existence.

If we already had full-grown subroutine keyword parameters, this could be written in a declarative way as:

sub foo( :$baz = 'Superman', :$bar, :$file, :$universe='DC' ) { }

(actually, I'm not sure if the above is correct for an invocation foo( baz => undef )).

But we don't have named parameters in the syntax yet, so we have to deparse the parameters ourselves:

sub foo( %options ) { ... }

Let's assume that option is a good name for this (I'm not convinced):

sub option ( $key, $def, $options ) { if( !exists $options->{ $key } ) { $options->{ $key } = $def; } return $options }

Then we could have a syntax like this:

sub foo( %options ) { option baz => 'Superman', option universe => 'DC', \%options; return \%options }

But I'm not entirely happy with this approach for two reasons:

  1. It doesn't strike me as overly elegant. I'm happy with it being not overly elegant, but there are some warts:
    • We pass in and modify the %options hash by reference. Alternatively we could do %options = option foo => 'bar', %options;, but that copies the whole hash a lot of times
    • We eagerly evaluate the default values, which might be costly in the case of function calls:
      option files => [glob('~/*')], option html => $user_agent->get('https://example.com'),
  2. There must be something like this on CPAN already

Test file:

AppVeyor failing to build/test CPAN distro
1 direct reply — Read more / Contribute
by jkeenan1
on Feb 20, 2025 at 22:09
    I am doing my annual revision and upload of an income-tax-related CPAN module. For testing on Windows (to which I myself don't have access), this year I added an AppVeyor configuration file (.appveyor.yml) essentially cloned from one of existing AppVeyor config files.

$ cat .appveyor.yml version: 1.0.{build} branches: except: - /travis/ skip_tags: true cache: - C:\strawberry -> .appveyor.yml install: - if not exist "C:\strawberry" cinst strawberryperl - set PATH=C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\str +awberry\c\bin;%PATH% - cd C:\projects\%APPVEYOR_PROJECT_NAME% - cpanm --installdeps . build_script: - perl Makefile.PL - gmake test_script: - gmake test TEST_VERBOSE=1 notifications: - provider: Email to: - [email protected] on_build_status_changed: true

However, the AppVeyor process repeatedly fails. Here's the relevant part of the output:

If I download the log.txt file from this run, the last 10 to 12 lines match the tail of the output above.

My other distros using .appveyor.yml configuration files build and test as expected, so I am at a lost as to explain why this one does not. Any suggestions?

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 wandering the Monastery: (3)
As of 2025-02-28 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found