Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

The Monastery Gates

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

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

Quests
poll ideas quest 2021
Starts at: Jan 01, 2021 at 00:00
Ends at: Dec 31, 2021 at 23:59
Current Status: Active
10 replies 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
New "miniconf" scheduled for 18th of November
on Aug 24, 2021 at 10:20
0 replies by hippo

    As announced in this dev.to post there is planned to be a one-day online "miniconf" for Perl and Raku in November. It will be held via Zoom and Thibault Duponchelle has posted the call for papers.

    The talks can be about toolchain, devops, cloud, sysadmin, core, design patterns, web or whatever linked to Perl or Raku.

    🦛

The ephemeral miniconf
on Aug 24, 2021 at 10:16
0 replies by contra-sh
    The ephemeral miniconf is a Perl and Raku virtual miniconf that will take place online the 18 november 2021. Follow the link (announcement/call for papers blog post) for details :)
Supplications
AWS EC2 and Perl
1 direct reply — Read more / Contribute
by Bod
on Oct 20, 2021 at 09:00

    Many will know that I need to upgrade from the current shared webhosting...it is overdue!

    A dedicated server would, of course, be ideal but I'm not sure I can justify the cost - I'm not totally convinced that I can't either! Plus, there is the server admin that I certainly don't have the time for or the skills for. The latter is solvable but not the time issue in the short-term.

    So, I thought about an AWS EC2 instance for all our webs services. This seems an ideal solution for a number of reasons:

    1. Once setup, take an image to restore if I mess things up
    2. Whatever version of Perl we want, we can install
    3. For testing, we take an image of production, spin up another EC2 instance and use that for testing/developing thus avoiding having a test setup and potential security holes
    4. No need to guess about the specs we need - AWS automagically scales as needed
    5. If one part of the business grows significantly, its easy to spin up another EC2 instance just for that
    6. Not as much server admin needed as a dedicated server but still some

    In some ways this seems too good to be true...
    Is this a plan worth looking further into or have a overlooked a flaw somewhere?

    We have databases of significant size - the biggest has 138 tables but only takes up 285Mb storage space. Plus we use Perl for everything! The shared hosting runs Apache but I have nothing to do with that other than some simple additions to the webroot .htaccess file.

Perl tutorial building on Python skills?
8 direct replies — Read more / Contribute
by LanX
on Oct 19, 2021 at 10:16
Assigning printf to a variable
4 direct replies — Read more / Contribute
by viffer
on Oct 19, 2021 at 09:53
    <grovel>Hi wonderful smart people </end grovel>

    Hopefully this makes sense
    I am processing an afp file
    I want to see the value of a certain string so I can use

    printf "Triplet_Values = <hex: %*v2.2X>\n", ' ', $data;
    The problem is this writes it to stdout

    What I want to do is assign it to a variable and write that variable to a log file, or pass that variable back to the calling routine
    eg something like

    my $variable=printf "--INSIDE Get_Triplet_Values = <hex: %*v2.2X>\n", +' ', $data; print LOG $variable
    But all the apostrophes are making it beyond my capabilities.

    Any help gratefully received.

Newbie question
6 direct replies — Read more / Contribute
by SpaceCowboy
on Oct 18, 2021 at 20:27
    Hi. I am currently exploring Perl and wondering:

    1. Is there a way to encrypt a Perl file containing password? I need to import database credentials from a file and would like to know more about encrypting passwords

    2. Pandas equivalent in Perl -- can I import a million rows and transpose, rename, transform and do a bunch of joins -- is this possible in Perl? I know I can write SQL and call it using DBI but not sure If I can get the table output and start performing transformations in it..

    3. Books/Resources recommendations -- any advice on books on perl deployment practices? docker?

    Thank you for supporting Perl and thanks in advance for your help!

read/write delete duplicates/sort PROBLEM! - Use of uninitialized value in sprintf
3 direct replies — Read more / Contribute
by VladP
on Oct 18, 2021 at 10:56

    Hi,

    The code below used to work but now I'm getting the error "Use of uninitialized value in sprintf at test.pl line 72, <FILE> ...". I don't understand what the issue is or how to fix it. It's suppose to take the input file "input.txt" and sort the value of TAGID then write the results to "output.txt". This was written by someone else at the time.

    It should open the input.txt file, remove any duplicates, sort with numerials first and then alpha (see sample output file), and write results to output.txt

    It's giving the error on this line:

    $tags{sprintf("%04d%6s",$1 || 999,$2)} = $tag;

    Syntax:

    >perl test.pl input.txt output.txt

    input.txt:

    <tagid=1>Test.</tag>
    <tagid=16ab>Test.</tag>
    <tagid=aa>Test.</tag>
    <tagid=16zz>Test.</tag>
    <tagid=39a>Test.</tag>
    <tagid=cc>Test.</tag>
    <tagid=de>Test.</tag>
    <tagid=16bc>Test.</tag>
    <tagid=zz>Test..</tag>
    <tagid=2>Test.</tag>
    <tagid=3>Test.</tag>
    <tagid=4>Test.</tag>
    <tagid=5>Test.</tag>
    <tagid=5a>Test.</tag>
    <tagid=5za>Test.</tag>
    <tagid=6>Test.</tag>
    <tagid=40>Test.</tag>
    <tagid=41>Test.</tag>
    <tagid=40>Test.</tag>
    <tagid=45>Test.</tag>
    <tagid=10ba>Test.</tag>
    <tagid=15xx>Test.</tag>
    <tagid=cc>Test..</tag>
    <tagid=ff>Test..</tag>
    <tagid=50>Test.</tag>
    <tagid=54>Test.</tag>
    <tagid=7>Test.</tag>
    <tagid=8>Test.</tag>
    <tagid=16yy>Test.</tag>
    <tagid=16ya>Test.</tag>
    

    output.txt

    <tagid=1>Test.</tag>
    <tagid=2>Test.</tag>
    <tagid=3>Test.</tag>
    <tagid=4>Test.</tag>
    <tagid=5>Test.</tag>
    <tagid=5a>Test.</tag>
    <tagid=5za>Test.</tag>
    <tagid=6>Test.</tag>
    <tagid=7>Test.</tag>
    <tagid=8>Test.</tag>
    <tagid=10ba>Test.</tag>
    <tagid=15xx>Test.</tag>
    <tagid=16ab>Test.</tag>
    <tagid=16bc>Test.</tag>
    <tagid=16ya>Test.</tag>
    <tagid=16yy>Test.</tag>
    <tagid=16zz>Test.</tag>
    <tagid=39a>Test.</tag>
    <tagid=40>Test.</tag>
    <tagid=41>Test.</tag>
    <tagid=45>Test.</tag>
    <tagid=50>Test.</tag>
    <tagid=54>Test.</tag>
    <tagid=aa>Test.</tag>
    <tagid=cc>Test.</tag>
    <tagid=de>Test.</tag>
    <tagid=ff>Test..</tag>
    <tagid=zz>Test..</tag>
    

    Code:

    require 5.000; use warnings; use strict; use POSIX; my %tags = (); my $input = $ARGV[0]; my $output = $ARGV[1]; open (FILE, "< $input") or die "cannot open $input: $!\n"; while (my $tag = <FILE>) { $tag =~ m/<x id=(\d*)([[:alpha:]]*)>/; $tags{sprintf("%04d%6s",$1 || 999,$2)} = $tag; } open (NEWFILE, "> $output"); foreach my $id ( sort keys %tags ) { print NEWFILE $tags{$id}; } close NEWFILE; close FILE;
POD for use feature 'declared_refs' wrong
2 direct replies — 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

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?
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 about the Monastery: (4)
As of 2021-10-21 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?