Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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
Win32::SysTray Issue
3 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 ;-)

Analysis Server access
2 direct replies — Read more / Contribute
by Shareef
on Oct 14, 2020 at 21:58
    Is there a way (a module) for a perl script running on Linux to access microsoft analysis server OLAP data base running on windows? I dont want a work around to aggregate the data using regular tables in sequal server.
accessing values
3 direct replies — Read more / Contribute
by frank1
on Oct 14, 2020 at 16:57

    How can i print the values from different filename using require

    perl file #!/usr/bin/perl my $var1 = "hello"; my $var2 = " perl!";
    perl #!/usr/bin/perl require ''; print $var1; print $var2;
Module design for loadable external modules containing data
4 direct replies — Read more / Contribute
by Discipulus
on Oct 14, 2020 at 12:31
    Hello folks,

    The title shows well the confusion I'm feeling about the matter :)

    For my Perl::Teacher project (see here and there) I plan to write a base class Perl::Teacher::Lesson and a Perl::Teacher::Course one aimed to just contain lessons logically grouped.

    In my intention me and others will write and release various courses in the form of Perl::Teacher::Course::EN::PerlIntro (for example) containing many different lesson modules like Perl::Teacher::Course::EN::PerlIntro::01_foreword etc.

    This is because the main Perl::Teacher object must be able to load a course and sequentially all its lessons at runtime.

    But I'm very confused about how to write these main base classes. Basically each lesson will be full of steps containing discourses, assignements, questions and, more importantly, tests to be run against student's perl programs (see the proof of concept to have an idea).

    The Perl::Teacher::Course::EN::PerlIntro::01_foreword module must be able to call methods from the main distribution but will contain a lot of data (texts and tests).

    Basically Perl::Teacher::Course::EN::PerlIntro::01_foreword can just have a mere @EXPORT exporting a big array/hash of data to be processed by the main Perl::Teacher object, but this sounds a bit primitive to me.

    How to provide a nice and easy to use interface to course writers?

    I have no experience with Moo and friends, so if you want to provide some sketch please take the patience and explain it plainly.

    I'm totally of the road? Complete redisign suggestions are also welcome if well explained.


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
perl and GraphQL example
2 direct replies — Read more / Contribute
by Krillian
on Oct 14, 2020 at 07:29

    I am trying to figure out how to post a request from perl to GraphQL API. I couldn't find any tutorials online. As far as I understand I can use this cpan module

    But I am still confused as to how to do it exactly. If someone could respond with an example, would be very much appreciated.

    Here is what I am trying to do: Send a post request to the API with a authentication header and body with query and graphql variables. I should then get a response in JSON, which I will process (this part I understand how to do).

    Thank you very much in advance!

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 scrutinizing the Monastery: (5)
As of 2020-10-21 10:37 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (213 votes). Check out past polls.