http://qs321.pair.com?node_id=479

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask.

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

Post a new question!

User Questions
POD for use feature 'declared_refs' wrong
1 direct reply — Read more / Contribute
by LanX
on Oct 16, 2021 at 08:49
    this POD is either confusing or plain wrong

    https://perldoc.perl.org/perlref#Declaring-a-Reference-to-a-Variable

      Beginning in v5.26.0, the referencing operator can come after my, state, our, or local. This syntax must be enabled with use feature 'declared_refs' . It is experimental, and will warn by default unless no warnings experimental::refaliasing is in effect.

    In reality is the warning disabled with no warnings 'experimental::declared_refs';

    the experimental::refaliasing warning belongs to https://perldoc.perl.org/perlref#Assigning-to-References

    Sample code:

    use strict; use warnings; use Data::Dump qw/pp dd/; use feature qw( declared_refs refaliasing say ); no warnings 'experimental::refaliasing'; my $a = [666]; my @a; \@a = $a; say $a[0]; no warnings 'experimental::declared_refs'; my \@arr = [42];

    C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/auto_ref.pl 666 Compilation finished at Sat Oct 16 14:45:33

    NB: that use feature qw(declared_refs) doesn't seem to make sense without the other feature.

    my \@arr; without assignment will create a new warning "Useless use of single ref constructor in void context"

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

Hash Curious
2 direct replies — Read more / Contribute
by cadphile
on Oct 15, 2021 at 19:21

    So, this is a curious construct, which I'd be interested in hearing some deep esoteric explanation for (basically, explain the assignment of the hash: @b{@f}=(); ). How does the hash get assigned by using the list symbol on it?

    $> perl -M'Data::Dumper' -le '@f=("f1","f2","f3"); my %b; @b{@f}=();pr +int Dumper(\@f); print Dumper(\%b)' $VAR1 = [ 'f1', 'f2', 'f3' ]; $VAR1 = { 'f1' => undef, 'f3' => undef, 'f2' => undef };
ROT8000 implementation?
3 direct replies — Read more / Contribute
by jwkrahn
on Oct 15, 2021 at 17:32

    I was just reading a CRYPTO-GRAM article about rot8000 and was wondering if anyone was working on a Perl implementation?

    FWIW, Google was no help.

    Update:

    Schneier on Security

    rot8000 translator

What's Perl good at or better than Python.
7 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 15, 2021 at 16:27

    Howdy Monks,

    I've used Perl in the past and was quite happy with it. But lots of folks use Python nowadays. So what is Perl better at than Python? Is my time better spent learning Perl or Python? And Perl faster than Python, especially when it comes to creating reports from text and putting in CSV or excel? Can Perl do parallel processing better than Python and most importantly, does regex and Perl Modules for CSV, ssh, excel, REST etc play well with parallel processing? I don't know anything about parallel processing but I'm sure I'll need it hence asking, because there's some text files that go 10000 lines or some that are 200MB PLUS in size..Asked a friend and he said Python is better at parallel processing so jus wanna know.

Perl equivalent of Watir
5 direct replies — Read more / Contribute
by Galdor
on Oct 15, 2021 at 06:31
    I've been given some web scraping tasks - Found Watir but I would rather use existing Perl experience than learn Ruby from scratch: http://watir.com/ I would like the solution to integrate with Chrome + brwoser automation, and some Perl Framework like Mojolicious. Any tips to get me started?
my within brackets
6 direct replies — Read more / Contribute
by Bod
on Oct 14, 2021 at 13:19

    I've come across this bit of code within an existing legacy script - not written by me

    (my $pname,my $sname)=split / +/,$rname,2;

    I'm wondering if it is functionally different to writing

    my ($pname, $sname) = split / +/, $rname, 2;
    I've tested the two against each other and they seem to behave exactly the same. But, is there some subtle difference my quick test has not uncovered?

Problem with regexp to match
5 direct replies — Read more / Contribute
by logangha
on Oct 14, 2021 at 11:18

    Hi

    I have this assignment

    When a string comes with below content

    01/LC-13/E10GbE-1,01/LC-14/E10GbE-1

    It must take numbers 13, 1, 14 and 1, in order as indicated

    And with this instruction is achieved

    perl -le '@m = ( "01/LC-13/E10GbE-1,01/LC-14/E10GbE-1" =~ /./\w+-(\d+) +/\w+-(\d+)(?=,./\w+-(\d+)/\w+-(\d+))/); print for @m'

    But when string comes with

    01/LC-13/E10GbE-1

    It must take numbers 13 and 1

    And when I run my example does not work

    $ perl -le '@m = ( "01/LC-13/E10GbE-1" =~ /./\w+-(\d+)/\w+-(\d+)(?=,./ +\w+-(\d+)/\w+-(\d+))/); print for @m'

    It does not return anything

    Which seems to be the trouble?

    I don't know much about regular expressions

    Regards.

Chrome freezes on windows when opened with WWW::Mechanize::Chrome
3 direct replies — Read more / Contribute
by bakiperl
on Oct 14, 2021 at 11:02
    My WMC scripts have suddenly stopped working on windows, but they still work fine on Linux. I am not sure if it was caused by the windows updates or the recent module updates. I hope Corion can check this.
    Here is a simple script that causes the freezing of the browser. It has been tested on 3 different machines and the result is the same.
    #!/usr/bin/perl -w use strict; use warnings; use 5.012; use WWW::Mechanize::Chrome; use Log::Log4perl ':easy'; Log::Log4perl->easy_init($TRACE); my $mech = WWW::Mechanize::Chrome->new( headless => 0, ); use Data::Dumper; my $res = $mech->get('https://egp.rutgers.edu/wmc.html'); say Dumper $mech->getResourceTree_future()->get; $mech->sleep (20);
Escape user name and password in LWP proxy call.
3 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 14, 2021 at 05:52

    Hi Monks, What is the best way to escape special characters like @, in username and password which is passed to the ua->proxy while using LWP::Useragent.
    I tried using URI::escape but it doesn't seem to be working.
    Thank you.

perl v5.28.1 install GPIB module fail
3 direct replies — Read more / Contribute
by jianfeng
on Oct 14, 2021 at 04:51
    I'm a new guy on perl, trying to install the below module on my windows10 64-bit OS, but fail. ActiveState Perl:v5.28.1 I also have copied the nmake into C:\VC6\Bin;

    please help me! thanks.

    C:\Users\jixi>cd C:\Perl64\cpan\build\gpib-0.30-0 C:\Perl64\cpan\build\gpib-0.30-0>perl Makefile.PL Use of uninitialized value in pattern match (m//) at C:/Perl64/site/li +b/ExtUtils/MM_Win32.pm line 40. Use of uninitialized value in pattern match (m//) at C:/Perl64/site/li +b/ExtUtils/MM_Win32.pm line 41. Use of uninitialized value in pattern match (m//) at C:/Perl64/site/li +b/ExtUtils/MM_Win32.pm line 42. Using interfaces: ni rmt Using instrument drivers: hp33120a hp3585a hp59306a hpe3631a Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Writing MYMETA.yml and MYMETA.json Use of uninitialized value $m[8] in join or string at C:/Perl64/site/l +ib/ExtUtils/MM_Unix.pm line 365. Generating a dmake-style Makefile Writing Makefile for GPIB Writing MYMETA.yml and MYMETA.json C:\Perl64\cpan\build\gpib-0.30-0>nmake Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. **to undefined at C:/Perl64/site/lib/ExtUtils/Install.pm line 141. NMAKE : fatal error U1077: 'C:\"Perl64\bin\perl.exe"' : return code '0 +xff'** Stop.
    Discipulus added code tags

Add your question
Title:
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":