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

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 2020
Starts at: Jan 01, 2020 at 00:00
Ends at: Dec 31, 2020 at 23:59
Current Status: Active
11 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
Tau Station Perl MMORPG Kickstarter Launched
on Oct 05, 2020 at 13:21
3 replies by Ovid

    There's a song by Shaggy, "It wasn't me", that is running through my head. If you're familiar with it, it's somehow both catchy and vile. I've had ex partners describe me that way.

    The song is running through my head because I'm not the one who accidentally launched the Tau Station Kickstarter several days early. But it's done.

    And they won't let us restart it.

    So maybe it's not our intended launch window. Maybe we weren't ready. But we're owning this. We're making this happen.

    Please help support the world's first Biblio-RPG. It's a massive, immersive, narrative sci-fi MMO. And it's over 400,000 lines of Perl. Let's show the world what Perl can do.

    Even if you don't want to join in, please share this with everyone!

    Here's the link to the Kickstarter.

    And here's a link to the game. It's free to play and runs in any relatively modern browser, so you won't need to download anything or spend any money. usable again
on Oct 01, 2020 at 05:12
2 replies by hippo
Any reason to use the Paws module over aws cli commands in perl script?
5 direct replies — Read more / Contribute
by nysus
on Oct 21, 2020 at 09:25

    What are the arguments for using the Paws module instead of just embedding commands like `aws ec2 run-isntances --image-id ....` into my perl script? I feel dirty just executing command line commands in my perl script and it doesn't feel very professional, but what's the harm, really?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Win32::SysTray Issue
4 direct replies — Read more / Contribute
by PilotinControl
on Oct 16, 2020 at 23:22

    Hello Monks!
    I have another issue that I am trying to wrap my head around the code is below:

    use strict; use Win32::SysTray; my $tray = new Win32::SysTray ( 'icon' => 'C:\images\logo.ico', 'single' => 1, ) or exit 0; $tray->setMenu ( "> &Test" => sub { print "Hello from the Tray\n"; }, ">-" => 0, "> E&xit" => sub { return -1 }, ); $tray->runApplication;

    The above code works as it should in standalone mode. However when I add it to a larger Win32::Console program only THIS code works:
    my $tray = new Win32::SysTray ( 'icon' => 'C:\images\logo.ico', 'single' => 1, ) or exit 0;

    The second part of the code never gets executed. If the second part of the code is added the program freezes. Any ideas? I believe it has to do with the $tray->runApplication; part conflicting with the Win32::Console. Thanks in advace!
Escape $ in JSON::XS decoded
4 direct replies — Read more / Contribute
by johnfl68
on Oct 16, 2020 at 16:27

    Hello, is there a any other way to escape the $ as a decoded JSON character?

    Google in their infinite wisdom decided to use the $ as part of value names:


    "updated":{ "$t":"2019-07-19T20:04:56.046Z"

    But DataDumper shows the current time:

    $VAR1 = { 'version' => '1.0', 'feed' => { 'xmlns' => '', 'updated' => { '$t' => '2020-10-16T19:55:33.294Z +' }, 'gs$rowCount' => { '$t' => '1000'

    I am trying to get the Feed Updated value, this gives me the current time, and not the time value of 2019-07-19 in this case:

    $updated    = $decoded_json->{feed}->{updated}->{'$t'};


    $updated    = $decoded_json->{feed}->{updated}->{'\$t'};

    Gives me: Use of uninitialized value $updated in concatenation (.) or string

    Normally I just escape the special character, but it seems to be interpreting it into something different, and I am not sure why? I don't usually have characters in JSON that need to be escaped like this.

    Everything else is working fine, except this one line. Am I missing something that I just haven't stumbled upon before? Any help would be appreciated as always.

    Thank you.

One liner is returning unexpected "1" on the output and I do not understand the mechanism at play.
1 direct reply — Read more / Contribute
by perlynewby
on Oct 16, 2020 at 12:49

    I am getting an unexpected output from a one-liner and I do not understand what it is I am doing wrong. the one-liner is outputting a "1" before the line number. I've tried to simplify the one-liner to try to understand the output but still eludes me but, maybe, someone here can part with some of the wisdom.


    name = Leah last_name = Pellegrini age = 32 profession = "artist" / "e +ngineer of all things" favorite_song = "I'm alive" performer = "Micha +el Franti" name = alberto last_name = Montelongo age = 32 profession = "cool + dude" favorite_song = "#41" performeer = "DMB" Name = Lucca last_name = montelongo age = 6 profession = "future Blue +Angel" favorite-song = "sunflower" performer = "Post Malone" Name = josh last_name = montelongo age = 26 profess +ion = "happy" favorite-song = "satellite" performer = "dmb" Name = josh last_name = montelongo age = 26 profession = "happy" favo +rite-song = "satellite" performer = "dmb"

    1) One-liner seeking to build up to do multiple things like only print odd lines, print lines with text only, OR print if regexp match. Then print line with no leading space, number of the lines, space out with a \tab.

     perl -lane 'print s/^\s+//,$., "\t", @F[0,1,2,],"\t",@F[3,4,5], if (($.%2) && /\w+/ || /cool dude/)' data.txt
    13 name=alberto last_name=Monte 5 Name=Lucca last_name=monte

    Please, notice the 1 before the odd line number 3, Why is that? Is my substitution not written correctly? I am replacing the space with no space. If I remove this substitution the output is fine but it is unexpected to me and I cannot understand the mechanism that is at work here with this substitution.

    2) Now, the same one-liner but printing the even lines.

    perl -lane 'print s/^\s+//,$., "\t", @F[0,1,2,],"\t",@F[3,4,5], if (($.%2==0) && /\w+/ || /cool dude/)' data.txt
    2 name=Marta last_name=Pellegrini 13 name=alberto last_name=Monte 16 Name=josh last_name=monte 8 Name=josh last_name=monte

    This is to illustrate the susbtitution in line 3 (satisfies OR condition) and 6(even lines). I'll appreciate and explanation why the substitution is outputing these ones.

    Additional challenge: count the repeating names in the data.txt. I did a ~tr/=// as a character count but unable to think of a counter for "name" to add to this one-liner ;-)

Cool Uses for Perl
Routines to help place widgets using Tk "grid" GM
No replies — Read more | Post response
by johngg
on Oct 20, 2020 at 06:51

    When using the "grid" geometry manager in a Tk application to place a number of, say, buttons it can be a little confusing when the number of widgets is not an exact multiple of the number of rows or columns constraining the layout. I came up with a small module that calculates the "x" and "y" for each widget, returning a ref to an AoA of widget positions. Here is the module:-

    Here is a test script that demonstrates its use:-

    I'm posting this in the hope that someone might find it useful.

    Update: Corrected typo.



Log In?

What's my password?
Create A New User
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: (3)
As of 2020-10-22 23:44 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (232 votes). Check out past polls.