Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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.

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
Consider learning Perl in 2021
on Oct 22, 2021 at 11:51
1 reply by reisinge

    I found this article referenced in login 2020 winter issue. It's about the ten most popular programming languages to Learn in 2021. The article mentions also seven other languages to consider learning. Perl is among those seven.

    hic et nunc
New "miniconf" scheduled for 18th of November
on Aug 24, 2021 at 10:20
0 replies by hippo

    As announced in this 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.


Variable with curly braces?
3 direct replies — Read more / Contribute
by wyt248er
on Oct 24, 2021 at 02:10

    The perl guide document "perlpacktut" contain the following command statements, which look like assignments.

    $UTF8{Euro} = pack( 'U', 0x20AC ); # Equivalent to: $UTF8{Euro} = "\x{20ac}"; $Unicode{Euro} = unpack( 'U', $UTF8{Euro} );

    The tokens `$UTF8{Euro}` and `$Unicode{Euro}` seem to be treated as variables. However, the typical perl variables I am familiar with are of the form $v or ${v} but not $v{u}. In fact, the following code ends up with an error.

    #!/usr/bin/perl my $v{u} = "hello"; print($v{u}, "\n");

    syntax error at ./ line 3, near "$v{u"

    What are `$UTF8{Euro}` and `$Unicode{Euro}`? Which perl guide document explain this kind of token?

    Thank you in advance.

How to convert between Unicode codepoint and UTF8 character code on Perl?
3 direct replies — Read more / Contribute
by wyt248er
on Oct 24, 2021 at 01:32

    I would like to convert between Unicode code points and UTF-8 character codes.

    For example, the Unicode code point for the GREEK SMALL LETTER PI is U+03C0, and its UTF-8 character code is 0xCF80. So, if the string "U+03C0" (or "0x03C0") is entered, then I want the string "0xCF80" to be printed (without quotes). If the string "0xCF80" is entered, then I want the string "U+03C0" (or "0x03C0") to be printed (without quotes). Note that the desired output is NOT a character itself but a string showing the character code.

    By the way, if your terminal is configured to display Unicode wide characters, then the following commands will show you the GREEK SMALL LETTER PI.

    perl -l12e 'print(chr(0x03c0))' -C perl -l12e 'print(pack("U0W*", 0xCF, 0x80))' -C

    Thank you in advance.

STDIN usage in interactive debug
1 direct reply — Read more / Contribute
by abdan
on Oct 23, 2021 at 23:26
    Why in interactive debug cannot do input:
    DB<1> @ln=<STDIN>; <"FILE" DB<2> print "$ln[0] $ln[1]"
    How to have it working directly
Dump the key value pairs in a hash
4 direct replies — Read more / Contribute
by byrnejb
on Oct 22, 2021 at 16:12
    I am not a perl programmer. I do have to maintain a legacy perl application. Something has changed in the environment so that it no longer correctly reports the status of public key certificates. I need to discover what that change is and how to accommodate it. The critical piece of code appears to be:
    sub genHTMLTableRow { my $self = shift; my $args = shift; my $e = shift; my $ser = $e->{serial}; my $pem = $ser.'.html'; . . .
    What I wish to do for debugging purposes is to dump the actual contents of $self, $args, and $e. I tried the naive approach of using print "$self\n"; but that just gave me this:
    I tried to use the map function
    print map { "Key: $_ has Value:$self{$_}\n" } keys $self;
    I clearly do not understand the naming conventions of perl variables as this usage of map causes the error:
    Global symbol "%self" requires explicit package name (did you forget + to declare "my %self"?) at /root/bin/rcsp/blib/lib/ line 861
    What is the perl way of displaying the contents of $self, $args, and $e?
AWS EC2 and Perl
3 direct replies — Read more / Contribute
by Bod
on Oct 20, 2021 at 09:00

    Many will know that I need to upgrade from the current shared 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?
9 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!

Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-10-25 23:30 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.