Skip to main content



I am using Selenium to obtain a numeric value from a website with code such as:

my @divwrap = $driver->find_elements('whatever', 'id'); my $return_value = $driver->find_child_element($divwrap, 'changeValue', 'class')->get_text(); 

This works fine, and returns the correct expected value.

If the value is POSITIVE, it return the plus sign, such as "+64.43"

But if the value is NEGATIVE, it returns a "wide Character" string: "" instead of the minus sign.

So the return looks like "64.43"

Interestingly, I cannot do a substitution.

If I have explicit code, such as:

my $output = "64.43" ; $output =~ s/"/\-/ ; 

... then $output will print as "-64.43"

... but if I try to do the same substitution on the return from the find_child_element function:

$return_value =~ s/"/\-/ ; 

... the substitution does not take... and printing $return_value continues to output "64.43".

Any ideas why it doesn't... and how to solve it?

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




I’m a dev with 20yoe in mostly Java and js but have various amounts of experience with other languages. I’ve decided that I need Perl in my toolkit because I find it on even the most minimal boxes preinstalled and I can’t always install Java or Js just to do admin things. Typically I use bash for these tasks but I just need a little more ability to abstract than what bash easily provides. What would you all recommend as the place to start? Most guides that I run into assume that I’m a beginner to programming and it feels slow. My normal method of learning a new language is to stumble through building a web server but I’m not sure that the way to go here.

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



I am working with the IP::Geolocation::MMDB module which replaces the deprecated modules for GeoIP databases.

I am having trouble understanding how to extract data.

my $ip = "8.8.8.8"; my $db = IP::Geolocation::MMDB->new(file => "$geolitecitydb"); my $geodata = $db->record_for_address($ip); print Dumper($geodata); 

Using Data::Dumper as above to show the results, I see something like (truncated):
Dumper...........$VAR1 = { 'continent' => { 'geoname_id' => 6255149, 'names' => { 'de' => 'Nordamerika', 'es' => "Norteam\x{e9}rica", 'zh-CN' => "\x{5317}\x{7f8e}\x{6d32}", 'ru' => "\x{421}\x{435}\x{432}\x{435}\x{440}\x{43d}\x{430}\x{44f} \x{410}\x{43c}\x{435}\x{440}\x{438}\x{43a}\x{430}", 'fr' => "Am\x{e9}rique du Nord", 'ja' => "\x{5317}\x{30a2}\x{30e1}\x{30ea}\x{30ab}", 'en' => 'North America', 'pt-BR' => "Am\x{e9}rica do Norte" }, 'code' => 'NA' 

Supposing I just want to grab the value of continent=>names=>en portion (value: 'North America') and write it to a value -- how would I do this? I'm having problems understanding the documentation I'm reading to deal with hashes of hashes.

Most examples I can find online involve looping through all of this; but in my case, I just want to make $somevar = 'North America.' I'd like to repeat it for other data as well, which is returned in this hash.

It feels like something like:

$geodata{city=>names=>en} should work, but it doesn't.

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




I have been using version 5.22.1 for years, and it did what I needed to do. After all these years, I need some additional functionality, so I thought installing the latest might help.

Which is when I found that ActiveState has changed the installation process totally. Anyway, I went through the installation of the "recommended" version, and installation seemed to go fine.

I then ran the following simple code through both versions.

use HTTP::Tiny; my $url ='https://www.scrapingcourse.com/ecommerce/' ; my $response = HTTP::Tiny->new->get($url); print $response->{content}; 

Version 5.22.1 runs this fine and gives me the HTML of the page.
Version 5.36.3 gives me the following errors;

IO::Socket::SSL 1.42 must be installed for https support
Net::SSLeay 1.49 must be installed for https support

When I use the old ppm command for Version 5.22.1, it gives me a list of 271 packages installed.

When I used the new "state" command: "state packages", it showed nothing.

So I used "state" to "install" IO-Socket-SSL, and Net-SSLeay, and now those are the only two that show up in the "state packages" list.

But it did not change functionality. The error messages are still there, and no execution.

It doesn't complain about HTTP::Tiny.

I tried installing Strawberry. But it had a problem with a more complex part of my original project, so I went back to ActiveState 5.22.1, which works fine.

Anybody got any ideas about what I need to do to get 5.36.3 actually working?

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




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


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


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]



Anybody wants to add a Perl implementation to this?

(I'm currently on a train and have to change soon, but if nobody implements I might give it a try later)

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




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



Enhancing non-Perl bioinformatic applications with #Perl: Building novel, component based applications using Object Orientation, PDL, Alien, FFI, Inline and OpenMP - Archive ouverte HAL https://hal.science/hal-04606172v1

Preprint for the #TPRC2024 talk to be delivered in 10days

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



This might be Perl/docker-perl#161 but if I filed this in the wrong place, let me know. Keeping these things current is the sort of thing I'd pay for.

Pulling perl images locally give the same warnings for old perl versions, although my local docker will still run them:

$ docker pull perl:5.14 5.14: Pulling from library/perl Image docker.io/library/perl:5.14 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 

Here's what I'm getting today from GitHub Actions. Sure, I see all sort of warnings to upgrade node, but nothing about this change:
/usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Warning: Docker pull failed with exit code 1, back off 5.148 seconds before retry. /usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Warning: Docker pull failed with exit code 1, back off 4.06 seconds before retry. /usr/bin/docker pull perl:5.14 5.14: Pulling from library/perl [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/ Error: Docker pull failed with exit code 1 

From this snippet in my GitHub workflows (e.g. .github/workflows/linux.yml)
 matrix: os: - ubuntu-22.04 perl-version: - '5.8' - '5.10' - '5.12' - '5.14' - '5.16' - '5.18' - '5.20' - '5.22' - '5.24' - '5.26' - '5.28' - '5.30' - '5.32' - '5.34' - '5.36' - 'latest' container: image: perl:${{ matrix.perl-version }} 

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



I have an input string that has "comments" in it that are in the form of: everything after a ; is considered a comment. I want to remove all comments from the string and get the raw text out. This is a pretty simple regexp replace except for the fact that ; characters are valid non-comments inside of double quoted strings.

How can I improve the remove_comments() function to handle quoted strings with semi-colons in them correctly?

```perl use v5.36;

my $str = 'Raw data ; This is a full-line comment More data ; comment after it Some data "and a quoted string; this is NOT a comment"';

my $clean = remove_comments($str);

print "Before:\n$str\n\nAfter:\n$clean\n";

sub remove_comments { my $in = shift();

$in =~ s/;.*//g; # Remove everything after the ; to EOL return $in; 

} ```

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



Hi,

im looking to put my website written in perl that currently runs locally inside apache out on the internet.

I dont want to host myself, and i dont have lots of spare time to config or money to spend for a vps.

Does anyone have experiences and can recommend a webhoster for maybe 10-15 bucks a month where i can just get a simple interface with ssh, where i can put an index.cgi somewhere(dont care if its in cgi-bin or public_html or something else,

i want something where i can just checkout my git repo thta contains index.cgi in its root and just works.

Thank you in advance!

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



Thanks to a pile of new data added and old data cleaned up (most of that work done by Philippe Bruhat and Aristotle Pagaltzis) and some help from Copilot on the Javascript, there's a lot of new, interesting information on my Perl Steering Council web page - https://psc.perlhacks.com/

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






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


I know it is something of an obscure corner of everything that Perl can do, but Perl is excellent for "one-liners".

Has anyone developed a module of convenience functions for use with one-liners? I have something in progress but I'd like to see if there is established prior art.

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



Stack:

Nginx FCGI CGI::Fast HTML::Template::Compiled Redis CentOS Linux 7.9 spawn-fcgi 

I have a Perl application that runs on the above stack.

On process init it does a lot of loading of big hashes and other data into global variables that are mostly preloaded and cached in a distributed Redis install.

To start the application spawn-fcgi creates 6-8 processes on a port nginx then connects to trhough their fcgi module.

The challenge:

— The init process is computing and time consuming; and doing that concurrently six times peaks CPU and overall leads to a ~20-25 second delay before the next web request can be served. And the initial request to each of the six processes has that delay.

I tried loading the content in question directly from Redis on demand but the performance keeping it in memory is naturally much better (minus the initial delay).

is there an architectural pattern that I am not considering here? I am thinking of things as eg. only spinning up one process, having it initialize and then clone(?) it a few times for serving more requests.

I could also think of a way where only 1 process is spawned at a time and once it completes initiation the next one starts; would need to verify that spawn-fcgi can support this.

So my question to this community is if I am missing an obvious better solution than what is in place right now / what I am considering.

Thanks in advance.

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



I am moving a pile of stuff off of an older Intel Mac Mini onto an M2. Have almost everything migrated, but am stuck on getting a Perl script that relies heavily on DBD::mysql to work. I finally got cpan to build the module, but when I try to use it in actual code, I get: dyld[82852]: missing symbol called. I go through this mess periodically with OS upgrades...and it's possible that this is (once again) OSX ignoring the module because it's not signed. But the given error sounds more like Perl not finding the dynamic library(s) the module was built with...if I just have a script containing "use DBD::mysql;", that doesn't throw an error, which suggests Perl found the module and loaded it. But chokes when it tries to use it.

I'd be fine with building this module with static libraries, if the process of doing so is easy. But have not seen an easy option to cpan to go that route. Suggestions?

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




If the length of some_array is 101 then the code below gives an illegal divide by zero error, but when the length of the array is 102 it's fine. I noticed that 101 results in a float and 102 results in a whole number. Maybe that has something to do with or maybe it's because the length of the array is unknown ahead of time. I'm not sure.
my $result = $some_value / scalar(split(",", $some_array[0])); 

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


ar_foo and $bar come from a text file.
This throws an illegal divide by zero error:
my @ar_foo = ("1", "2", "3"); my $bar = "5"; my $x = $bar / scalar(@ar_foo); 

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






This is the frame body I was using:

our $frame_body = $mw->Frame(-background => $color_theme_bg, -foreground => $color_theme_fg)->pack(-side => 'top'); 

And I have many widgets like labels, dropdowns, buttons, etc... within that frame like below:
 $frame_body ->Label( -text => "@_", -font => $arial_font, -foreground => $color_theme_fg, -background => $color_theme_bg, -highlightthickness => 0, -takefocus => 0, -relief => "flat", -justify => 'center', )-> grid( -column => $mw_col_ctr, -row => $mw_row_ctr, -sticky => "nsew", ); 

May someone help me the best way to apply a "vertical scroll bar" on the right side of this frame?

Its also nice if automatically adjust incase I manually resize the window. 😀

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




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


Is there a way to replace accented characters by their plain version, something like

tr/ûšḥ/ush/?

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



List of new CPAN distributions – May 2024 submitted by /u/perlancar
[link] [comments]



Is it possible to display an image to the user, without loading all the trappings of a whole widget / event-loop environment like Prima, Tk, Wx, Win32::GUI, etc?

Specifically, I want something simple that I can execute in a BEGIN block to display a splash image to the user while the rest of the application is compiled and initializes, which takes about 5-10 seconds. The program in question is a perl Wx application running under MS Windows.

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




Vim highlights subs with a signature params as red/orange to alert you it's incorrect. Now that Perl actually supports signatures and this is no longer a syntax error I need to find a way to disable this. This is really a Vim question, but I'm sure some other Perl nerd out there has run into this before me.

Has anyone figured out how to disable this "warning" in Vim?

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