Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Seekers of Perl Wisdom

( #479=superdoc: print w/replies, xml ) Need Help??

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
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?
1 direct reply — 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.
2 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
2 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
Errors uncaught by CGI::Carp
2 direct replies — Read more / Contribute
by Bod
on Oct 13, 2021 at 16:46

    This is a follow on from the second part of the question I asked in CGI::Carp fatalsToFile
    The collective wisdom of The Monastery solved the first issue but not the second...it seems they are unrelated!

    I am getting 500 errors intermittently from most, if not all of the pages of a website. The errors seems to be clumped together over time. In other words, once an error happens it seems likely that it will happen again quite soon. Whereas at other times we go quite a while without errors.

    Every script has use CGI::Carp qw(fatalsToBrowser); at the start of the script.
    The bit I am most confused about is that my understanding is that, with fatalsToBrowser the only two ways to get a 500 error is that the script has the wrong permissions or that the script doesn't return valid HTTP headers. As this is an intermittent problem, it is neither of these.

    This is the code of the modules that are common :

    package Site::HTML; use strict; use warnings; use DBI; #use DBD::mysql; use Exporter; use Template; use MIME::Lite; use Digest::SHA qw(sha256_base64); use cPanelUserConfig; use Site::Variables; use Bod::CRM; our @ISA = qw(Exporter); our @EXPORT = qw(%data %file %cookie $dbh $current_user); our $site = $Site::Variables::site; our $template = Template->new( INCLUDE_PATH => $Site::Variables::template_path, PRE_CHOMP => 0, POST_CHOMP => 1, ); our (%data, %file, %cookie, $dbh); our $current_user = 0; my $crm = Bod::CRM->new($Site::Variables::env_crm_env); # Untaint ENV{PATH} for MIME::Lite my $path = $ENV{'PATH'}; $ENV{'PATH'} = undef; foreach my $p(split /:/, $path) { if ($p =~ m!^(/(usr|bin).*)!) { $ENV{'PATH'} .= ':' if $ENV{'PATH'}; $ENV{'PATH'} .= $1; } }
    and
    package Site::Wayfinder; use strict; use warnings; use cPanelUserConfig; use Digest::SHA qw(sha512_base64); use Facebook::Graph; use GD; use Bod::CRM; use Site::HTML; use Site::Point; my $crm = Bod::CRM->new(Site::HTML->crm_env); sub new { my $class = shift; my %attrs = @_; $attrs{'error'} = ''; $attrs{'fb'} = Facebook::Graph->new( app_id => '12345678', secret => 'abcdefghijklmnop', postback => "https://$ENV{'HTTP_HOST'}/?command=authori +ze_facebook", ); return bless \%attrs, $class; }
    I have commented out use DBD::mysql; because on one occasion I got some output from CGI::Carp that showed an error on that line. I have not been able to replicate this error. Not specifying a DBD driver forces DBI::DBD to use the driver in it's config which is setup to connect to the MariaDB database.

    My only hunch is that, because errors seem more concentrated at certain times, it is connected with the number of concurrent users. This in turn makes me wonder if is is Facebook::Graph that is the problem as it is deprecated. We only use Facebook for authentication. Users can create an account using Facebook rather than creating a password or can sign into an existing account using Facebook provided the email addresses are the same. This works under normal circumstances.

    It isn't just web browsers that are getting the error. Facebook is complaining that our privacy policy page is giving errors and Stripe gets occasion webhook errors.

    I am unable to replicate the problem on our test site - it only seems to happen on the live production site. Therefore I am limited on how much I can test or what I can tweak!

    Any ideas what I can do to try and get some understanding of what is going on?

    UPDATE: - to test my hunch that it is to do with multiple users, I have tried to cross referencer 500 errors with the data collected by Google Analytics and Hotjar. But the errors are not written to the Apache error log so this is proving difficult. I have started having Google Analytics open when I access the site so that I can look at the real time data when I next see an error.


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":


  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2021-10-16 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?