Skip to main content



Its been a long time since i've had to hack some code together so here just asking for advice as to where to start.

I have a group of printers (all have same web interface) on the corporate network. I would like to make a simple script that can login, and upload a config file (really its a list of users that have can scan documents, it doesn't matter what).

I've tried to google this with limited results, so wanted to reach out here to see if PERL would be the best answer for this.

I guess my question is, what modules should I look at to connect to a webpage in order to login then access a page behind the login and upload a file?

I looked into Mechanize but I do not believe it can handle javascript. Any advice or test scripts that do something similar would be greatly appreciated.

submitted by /u/hsvodka
[link] [comments]



I’m currently having to modify a library that used Smart::Match extensively since I can no longer turn off the zillions of lines of experimental warnings in recent Perls. For people who are in a similar situation it’s looking like Data::Compare can replace the situations where I was doing ‘@foo ~~ @bar’, and it’s easy enough to write a “does this hash have this key” helper.

Meta complaint: I was already a bit annoyed at the whole smartmatch “oh whoops actually this is now experimental” saga but now that I’m stuck fixing this breakage I’m $annoyed++. Im getting annoyed enough that I may choose an older Perl that was “good enough” and just stop using the new ones

See also: https://www.reddit.com/r/perl/comments/pimwma/how_do_i_stop_smartmatch_is_experimental_at/

submitted by /u/lovela47
[link] [comments]



Hello all I have a .pl CGI program that calls a module with lots of code I'll call it LotsOfCode.pm now I need to update a few subs in it and possibly add a dependency.

The pl file looks like this:

main.pl

use LotsOfCode;

Lotsofcode->cat();

LotsOfCode->dog();

Lotsofcode->fish();

Now I'd like this to say the same but I need to improve fish and cat. Say LotsOfCode.pm looks like this:

package LotsOfCode

sub fish {}

sub dog {}

sub cat {}

1;

I'd like to

mkdir ./LotsOfiCode

nano LotsOfCode/fish.pm move sub fish{} here

nano LotsOfCode/dog.pm move sub dog {} here

nano LotsOfCode/cat.pm move sub cat {} here

what do I put in the top of these new files in \LotsOfiCode ?

package LotsOfCode::fish;

or

package fish; ?

or

nothing is what I have so far just

sub fish {}

then in LotsOfCode.pm

do I go:

package LotsOfCode

use LotsOfiCode::fish

use LotsOfiCode::dog

use LotsOfiCode::cat

1;

or

do LotsOfCode::fish;

do LotsOfCode::cat;

do LotsOfCode::dog;

Thank you all in advance I get the more than one way to do it idea of Perl but feel like I keep fumbling with mixing old and new code.

submitted by /u/bug_splat
[link] [comments]



Why is "!!" considered bad form in Perl? [updated for 2024] submitted by /u/EvanCarroll
[link] [comments]


Filed under "Things that one can do, but why?" , here is the repo of using Perl to learn assembly, or rather use Perl to avoid

  1. having a C driver program
  2. make files
  3. multiple files (Inline::ASM allows one to keep Perl and Assembly in the same file

Bonus :

  1. it is insane how efficient some of the list utilities at List::Util are !
  2. Seems Github uses file extensions to count lines of code in a language (the repo is considered all Perl

Link https://github.com/chrisarg/perlAssembly

submitted by /u/ReplacementSlight413
[link] [comments]



Asking for a friend. No really, I don't use VSCode but I know that a lot of people do and in one week I had two different people ask me this. I didn't see anything in the Visual Studio Marketplace. I'm looking for something like markdown-preview enhanced, but for Pod.

If you don't have that, is it something that you would want?

If it's something you want, would you throw in some money to have it? This isn't something I'd do myself, but I know some people with some free time who could use a little money. I could crowdfund it or whatever. The intent is to have something free in the Marketplace.

Would you care if it's not implemented in Perl? If it was JS or whatever VSCode prefers but does the job, that's fine with me (and remember I don't use VSCode). I have no idea how much that matters, but I'd hate for people to have to do all sorts of crazy setup, which for many people is installing anything from CPAN.

submitted by /u/briandfoy
[link] [comments]



Function parameters of arrays sized m, n → m+n is the hello world of dependent types. I hacked this together over two evenings:
use 5.038; use strictures; use Kavorka qw(fun); use Moops; our %TypeVarRegistry; class MyTypes extends Type::Library :ro { use Type::Library -declare => qw(TypeVar TypeVarExpr); use Types::Common::String qw(NonEmptyStr); use Types::Standard qw(ArrayRef); use Types::Common::Numeric qw(PositiveOrZeroInt); my $TypeVar = Type::Tiny->new( name => 'TypeVar', constraint_generator => fun(NonEmptyStr $name → CodeRef) { fun {} } ); my $TypeVarExpr = Type::Tiny->new( name => 'TypeVarExpr', constraint_generator => fun(NonEmptyStr $name → CodeRef) { fun {} } ); my $SizedArray = Type::Tiny->new( name => 'SizedArray', parent => ArrayRef, constraint_generator => fun( Enum["type"] $literal_type, Type::Tiny $parameterized, Enum["length"] $literal_length, $expr → CodeRef ) { if (PositiveOrZeroInt->check($expr)) { fun { $expr == ArrayRef->of($parameterized)->assert_return($_)->@* } } elsif ('TypeVar' eq $expr->parent->name) { fun { $TypeVarRegistry{$expr->parameters->[0]} = ArrayRef->of($parameterized)->assert_return($_)->@*; 1 } } elsif ('TypeVarExpr' eq $expr->parent->name) { fun { my $eval; # world's worst symbolic expr parser if ( my ($var1, $op, $var2) = $expr->parameters->[0] =~ /(\w+)(\+)(\w+)/ ) { $eval = $TypeVarRegistry{$var1} + $TypeVarRegistry{$var2}; } else { die; } $eval == ArrayRef->of($parameterized)->assert_return($_)->@* } } else { die } }, ); __PACKAGE__->meta->add_type($_) for $TypeVar, $TypeVarExpr, $SizedArray; __PACKAGE__->meta->make_immutable; } use MyTypes qw(SizedArray TypeVar TypeVarExpr); fun add_ok( SizedArray[type => Str, length => TypeVar["m"]] $A, SizedArray[type => Str, length => TypeVar["n"]] $B → SizedArray[type => Str, length => TypeVarExpr["m+n"]] ) { [$A->@*, $B->@*] } use Data::Dx; Dx add_ok([qw(e r t)], [qw(e r t)]); fun add_broken( SizedArray[type => Str, length => TypeVar["m"]] $A, SizedArray[type => Str, length => TypeVar["n"]] $B → SizedArray[type => Str, length => TypeVarExpr["m+n"]] ) { [$A->@*, $B->@*, 'this must not work'] } use Data::Dx; Dx add_broken([qw(a s d f)], [qw(g h j k)]); 

submitted by /u/daxim
[link] [comments]


I need to find the distance between two GPS coordinates. Geo::Calc does this effectively, but it hasn't been updated in over a decade, and, more seriously, it adds a significant startup delay just by loading the module:

root@1c8fb16bd7bb:/app# time perl -e 'use v5.38' real 0m0.005s user 0m0.001s sys 0m0.004s root@1c8fb16bd7bb:/app# time perl -e 'use v5.38; use Geo::Calc' real 0m0.679s user 0m0.631s sys 0m0.048s 

This isn't a deal-breaker (honestly, it barely matters at all in production, but it's annoying for repeated loads during dev/testing), but I was wondering if anyone knew of a more-modern/more-efficient alternative. I searched google and metacpan but it's tough to wade through the noise for such a generic search term.

submitted by /u/tyrrminal
[link] [comments]



The portions of B::Generate associated with PADOP construction use static variables, and thus are not thread safe.

This release imports that section of Generate.xs into sealed.xs and removes the static variable dependencies.

submitted by /u/joesuf4
[link] [comments]



submitted by /u/niceperl
[link] [comments]


Mo utilities for email.

Changes for 0.02 - 2024-04-26T23:02:53+02:00

  • Add tests for error parameters.
  • Rewrite the tests so that the functional tests are first and then the errors.






Code coverage metrics for Perl

Changes for 1.41

  • Spelling, linting and formatting changes



Experimental features made easy

Changes for 0.032 - 2024-04-25T22:30:41+01:00

  • Add the newly-stable features to stable.pm - extra_paired_delimiters, const_attr, for_list



Fetch actual raw streamable URLs from various radio-station, video & podcast websites.

Changes for 2.30 - 2024-04-25

  • StreamFinder::Castbox - Refactor to scrape episode data from the podcast page as now Castbox episode pages are no longer scrapable (now dynamically generated by javascript), but for now, all required episode data is embedded in the corresponding podcast page (for now). Also now append "lyrics" (transcript) to the "description" field (for Fauxdacious, etc.) for Castbox pages that provide this in a "lyrics" (.lrc) link!
  • StreamFinder::Google - REMOVED since Google has officially closed down it's podcast service.
  • StreamFinder::Podchaser - Fix failure to fetch episode data for the first episode (when a podcast page given) and failure to fetch all due to minor changes in their site.
  • StreamFinder::Spreaker - Refactor since Spreaker has now javascripted and cookied up their pages, but we're still able to scrape it's podcast pages for podcast metadata, required playlist data and 1st episode ID, and they provide a separate api site for fetching all episode data when given the episode-ID.
  • StreamFinder::Subsplash - Fix extraction of the artist & album fields due to minor changes in their site. Also add missing "Url" (first stream) field (not required for fetching streams).


Hi! Asking for a wisdom here...

We have a module that modifies signal handler $SIG{__DIE__} to log information and to die afterwards. Hundreds of scripts relied on this module which worked fine in perl 5.10.1.

Recently we had the opportunity to install several Perl versions but unfortunately a large number of scripts that used to work with Perl 5.10.1 now behave differently:

  • Failed in 5.14.4: /home/dev/perl-5.14.4/bin/perl -wc test.pl RECEIVED SIGNAL - S_IFFIFO is not a valid Fcntl macro at /home/dev/perl-5.14.4/lib/5.14.4/File/stat.pm line 41
  • Worked without changes in 5.26.3: /home/dev/perl-5.26.3/bin/perl -wc test.pl test.pl syntax OK
  • Worked without changes in 5.38.2: /home/dev/perl-5.38.2/bin/perl -wc test.pl test.pl syntax OK

Many of the scripts can only be updated to 5.14.4 due to the huge jumps between 5.10 and 3.58; But we are stuck on that failures.

Was there an internal Perl change in 5.14 which cause the failures but works on other recent versions without any update on the scripts?

Cheerio!

submitted by /u/Longjumping_Army_525
[link] [comments]



Sanity-check calling context

Changes for 0.04

  • (no code changes)
  • Switched to MIT license.
  • Switched README from POD to Markdown.
  • Removed Travis CI.



Sort lines of text by a Comparer module

Changes for 0.002 - 2024-03-07

  • No functional changes.
  • [doc] Mention some related links.


An assortment of date-/time-related CLI utilities

Changes for 0.128 - 2024-03-07

  • [clis strftime, strftimeq] Use localtime() instead of gmtime(). We can still show UTC using "TZ=UTC strftime ...".