Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

The Monastery Gates

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

Donations gladly accepted

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

Quests
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
Strawberry Perl 5.32.0 is now officially available.
on Aug 30, 2020 at 10:16
0 replies by syphilis
    kmx has finally responded to the issue I raised more than 3 weeks ago with responses of "fixed" and "closed".

    UPDATE: My mistake - the assertion (below) that the issue is NOT fixed is rubbish. It's just that I can't tell the difference between "5.32.0" and "5.30.2".
    AFAICT, the issue I raised is NOT fixed, but if you visit http://strawberryperl.com/releases.html you'll see that, in addition to the listing of perl-5.30.3 builds, perl-5.32.0 builds (which have been sitting on the Strawberry Perl server for at least a week or two) are, as of a few hours ago, now also officially available.
    That's about all I know ... with little expectation that kmx will provide any additional information.

    Cheers,
    Rob
German Perlmongers Online Meeting
on Aug 04, 2020 at 12:59
1 reply by LanX
    @ All German speakers here:

    Next German PM Online Meeting in (cough) 30 minutes.

    Announcement:

    Hallo Perlmongers aus den deutschsprachigem Raum,

    Heute, am Dienstag, den 4. August 2020, um 19:30 Uhr ist German-PM Online-Treffen im Jitsi.

    Dank Corona wurde das Online-Treffen mehrfach in Erlangen und Frankfurt ausprobiert. Der Wunsch wurde geäußert, das online neben den Treffen vor Ort weiterzuführen.

    Nimm an der Besprechung teil: https://meet.jit.si/German-PM

    I'm not the organizer, but I'll use this thread for future announcements.

    UPDATE

    on Daxim's request

    NO REBROADCAST WITHOUT PERMISSION!

    ONLY PRIVATE RECORDING ALLOWED!

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Supplications
Perl script for capturing SNMP Alerts.
3 direct replies — Read more / Contribute
by Anonymous Monk
on Sep 12, 2020 at 05:26

    Respected Monks,

    I have written perl scripts to automate some health check on various storage devices. To that end, I find Perl extremely flexible and sheer joy to code in.

    However, I am now planning to write a script that will monitor the storage device and if any failure occurs, it will send out an email. I have very basic idea of how SNMP works and I have been through the Net::SNMP documentation, but not sure how it will talk to the SNMP server, or will ports 161, 162 need to be opened from / to the server on which the script is running & the SNMP Server?

    Please note, I am not looking for ready made code. I just need pointers.

    I just realized that I need to read up on SNMP as well to really understand how it works, but in the interim, any pointers you provide will be a great help. I was here a long time ago and you folks had suggested some truly amazing modules and some great pointers...hoping for the same this time too.

Can module building tools deal with .pl files in lib/
2 direct replies — Read more / Contribute
by Smonff
on Sep 11, 2020 at 16:10

    I am playing with Zydeco and have a lot of questions those days.

    Not related to Zydeco, but this is a question that came because of the tests I did with it. This is more about the usual authoring and module building tools. I usually use Minilla because it is high level and it made my life super simple for something like 3 years, but I just encountered an issue. I then read the documentation of at least:

    • Module::Build::Tiny
    • Module::Build
    ...but didn't find an answer. I guess it would be easier to ask some fellow monks.

    So there is a very abnormal situation: I have .pl files in lib/. I know this is weird and not recommended, but I am using a third party tool from a rather experienced CPAN author, so I guess this is on my side that there is a problem. My files and directory tree looks like the following:

    $ tree ./lib/ ./lib/ Art Abstractions.pl Wildlife/ Buyer.pl Collector.pl Wildlife.pm World.pm Art.pm

    The reason that there are some .pl files in this area is something imposed by Zydeco (as far as I can understand) when you want to include some classes or roles. I don't want to open a debate on this, this is how things are. My tests are passing fine when I do something like prove -l t/.

    The issue starts to happen when I enter some traditional building and authoring. I first used Minilla, and then Module::Build::Tiny. Here is the output:

    $ mbtiny test Creating new 'Build' script for 'Art-World' version '0.06' cp lib/Art.pm blib/lib/Art.pm cp script/art.pl blib/script/art.pl cp lib/Art/World.pm blib/lib/Art/World.pm cp lib/Art/Wildlife.pm blib/lib/Art/Wildlife.pm t/01-basic.t .......... ok t/02-entities.t ....... No such file: Art/Wildlife/Buyer.pl at /tmp/ +WcGB64xtpH/blib/lib/Art/Wildlife.pm line 5. BEGIN failed--compilation aborted at /tmp/WcGB64xtpH/blib/lib/Art/Wi +ldlife.pm line 5. Compilation failed in require at t/02-entities.t line 3. BEGIN failed--compilation aborted at t/02-entities.t line 3. t/02-entities.t ....... Dubious, test returned 255 (wstat 65280, 0xf +f00) No subtests run Test Summary Report ------------------- t/02-entities.t (Wstat: 65280 Tests: 0 Failed: 0) Non-zero exit status: 255 Parse errors: No plan found in TAP output Files=5, Tests=1, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.48 cus +r 0.04 csys = 0.56 CPU) Result: FAIL
    All the different modules building and authoring tools gave me the same result: .pl files in lib/ are not copied to the build area and cannot be found. I dunno what to do with this situation and despite of searching in various configuration parameters, I didn't find promising paths. I guess I am missing something, but dunno what?

Perl script for body rewrite
3 direct replies — Read more / Contribute
by fgarpe
on Sep 11, 2020 at 07:55

    Hi Monks,
    this is my first post in this site and I'm a new user... also i don't have much knowledge of perl :(, sorry. I know that perl it's a great language with which you can do fantastic things, but my work has taken me in other directions. Now my question.

    I want to add a warning message like this:

    CYBER SECURITY WARNING: This email is from an external source - be careful of attachments and links

    In top of all incoming emails that come from external sources using exim, the best option that I can see is write a script thats is calling during transport, this script can read the entire mail and can do some modifications to it. In the exim docs are an example writed in perl, and seems like this is the best option to do this. Using this script as base I have done this:

    please don't laugh too much :D

    #!/usr/bin/perl $/ = ""; # set paragraph mode chomp($headers = <STDIN>); # read a paragraph, remove trailing newlin +es $/ = "\n"; # unset paragraph mode printf(STDOUT "%s\n\n", $headers); while (<STDIN>) { if ($_ eq "Content-Type: text/plain; charset=utf-8\n"){ $p = 'y'; } if ($_ eq "Content-Type: text/html; charset=utf-8\n"){ $y = 'y'; } printf(STDOUT "%s\n", $_); if ( $p eq 'y'){ printf (STDOUT "%s\n", "WARNING IN PLAIN TEXT") ; $p = 'n'; } if ( $y eq 'y'){ printf (STDOUT "%s\n", 'HTML WARNING') ; $y = 'n'; } }

    with the first tests everything seemed to work well, but when I tested it with real emails I had received the bugs began to appear. According to the MIME standard there are a lot of headers that can appear in the mail body (Content-Type, Content-Disposition, Content-Transfer-Encoding, etc), see the following link for more info:

    https://en.wikipedia.org/wiki/MIME

    I don't have always the same headers, sometimes they appear just above de body, others there are others headers before the body, depends on the origin server, some examples at bottom. I'm desperate and frustrated.

    Can someone help me to extract only the part of the message, either in html, in plain text or coded in base64 so I can add the warning?

    Thank you very much

    ------------------------------- SOME EXAMPLES -------------------------------

    Example 1:
    MIME-Version: 1.0
    Content-type: text/html; charset=iso-8859-1
    From: ******** <*******@**********>
    Message-Id: <20200910203400.8DD062046864@********>
    Date: Thu, 10 Sep 2020 22:34:00 +0200 (CEST)
    ... more headers ...
    the html message

    Example 2:
    x-ms-exchange-transport-crosstenantheadersstamped: DB6PR0501MB2792
    Content-Type: multipart/related;
    boundary="_005_DB6PR0502MB2934154A8B24C72DCD99E1E78A240DB6PR0502MB2934_";
    type="multipart/alternative"
    MIME-Version: 1.0
    ... more headers ...
    Content-Type: multipart/alternative;
    boundary="_000_DB6PR0502MB2934154A8B24C72DCD99E1E78A240DB6PR0502MB2934_"

    --_000_DB6PR0502MB2934154A8B24C72DCD99E1E78A240DB6PR0502MB2934_
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: base64

    the message in plain text encoded in base64

    Content-Type: text/html; charset="utf-8"
    Content-Transfer-Encoding: base64

    the message in html encoded in base64

    Example 3:
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="----=_Part_2475097_1688559153.1599727641537"
    Thread-Topic: *************************************************************
    Thread-Index: AdaFB4a1gtdC+dbyQ2GK8Qrlu/b37EPAIenT

    ------=_Part_2475097_1688559153.1599727641537
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: quoted-printable

    the message in plain text

    Content-Type: application/pdf;
    name="=?utf-8?filenamef?="
    Content-Disposition: attachment;
    filename="=?utf-8?filename?="
    Content-Transfer-Encoding: base64

Manipulating Array Indexes
12 direct replies — Read more / Contribute
by TJ777
on Sep 07, 2020 at 11:57

    Hello Perl Monks...I come today on bended knee humbly begging for any wisdom you can provide...

    I am trying to find elements in an array that are positioned 1, 2 and 3 places behind my 'target' element. So if my list is: 1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1, and my 'target' number was 5, I am looking for a way to return elements 6,7,8, and 4,3,2, I need to get the three elements after every time a 5 appears in the list. In actual practice the list will not be sequential and will be somewhat longer, but nowhere near consuming all my memory kinda long, maybe 200-300 items max.

    I can get the index of my target number easily enough, however I am wondering if there is a way I can manipulate the index values to 'look ahead'. I've been trying many variations of:

    $idxvalue = (pop(@indexes)+1); print "$lines[$indexes[$idxvalue]]\n";

    but I am having a hard time finding something that works. It's odd because when I print @indexes I get a list of the index numbers as expected, but then at times I am getting the actual item from the list, rather than the index position number I wanted. Please forgive my ignorance...I am trying my best....which admittedly is not very good :-(

    I'm using Strawberry Perl on Windows 10 in case it matters.... Thank you in advance to any who can offer suggestions or advice! TJ.

Is it safe to use join on a hash?
7 direct replies — Read more / Contribute
by pritesh_ugrankar
on Sep 06, 2020 at 18:49

    Respected Monks,

    The code given below is something I've written as a test.

    use strict; use warnings; use diagnostics; my @nums = (17, 10, 20, 33, 30, 40, 10, 33, 40, 15, 16, 17); my %unordered = map { $_ => undef } @nums; my @un_nums = join " ", keys %unordered; print "@un_nums\n";

    And it seems to work fine.

    D:\perlscripts>perl test.pl 30 17 33 10 40 15 16 20

    I'll be using this in a script to gather some information, therefore kindly let me know if 1) It's ok to use a join on a hash? 2) It's ok to collect the output of a join as an array context? Or is this a bad practice? Any side effects?

Meditations
Diary of a Zydeco experiment
4 direct replies — Read more / Contribute
by Smonff
on Sep 10, 2020 at 07:58

    Here is the first post of a small journal I want to keep about an experiment I will do with Zydeco. I hope the Perl Monks Meditations section is appropriate for this, if not, please feel free to redirect me on a better place (especially this is almost my first post here). I started to learn using Zydeco this week after suddenly getting abnormally excited about it. I guess Toby Inkster's marketing seemed to be very effective on me.

    Where am I coming from? I was mainly trained on Java in 2009, so I am a object-native programmer. I mean, I cannot really imagine building something that wouldn't be made of objects, but also, Perl doesn't enforce object orientation, so you can still do without it. I don't know a lot about the how Perl's built-in OO works. I mostly used some modules:

    • Moose - it is the de-facto OO module, recommended in lots of books and tutorials. I went into it when some systems I designed started to grow. You can do a lots of things with it, but it's difficult to use for prototyping for example
    • Mojo::Base - It is usually not described as an independent OO system, but it provides attributes and accessors, readable source code, methods, roles (through Role::Tiny), method signatures. It is extremely simple to use even for prototyping, just use Mojo::Base. I got so used to it while working on Mojolicious projects that I usually import it even on non-web project!
    • unfortunately, I don't think I ever tried Moo seriously

    Next time I'll speak about the purpose of my experiment that is in fact an artistic project: trained as an artist, I accidentally became a professional web developer while trying to learn skills for my next conceptual art piece. But nothing went in the right way. Ten years afters, I am still working on it.

Getting better at this?
2 direct replies — Read more / Contribute
by Lady_Aleena
on Sep 06, 2020 at 20:29

    Hello everyone.

    I think I have made some improvements on how I write and use what I write.

    Since I began using git, I have made several changes to my code for my site.

    First, I moved everything used only for my site and have no intention of sharing on CPAN into one directory/name space called Page, This is the code so many dislike, so now it is all in one place away from everything else most are somewhat neutral about.

    After that bit of reorganization, I wanted to get the code not used for my site away from my site's code, so decided to do something about it. After a lot of digging on CPAN to get some site related code out, I had to know where to put external data used in half a dozen modules. It took me a while to figure it out. Once I did, File::ShareDir made it into my code.

    Next, I had to get my site's modules out of PERL5LIB, so I finally used FindBin after fighting against it all these years. I had been putting my site's lib into PERL5LIB since I was using Windows XP. It followed through when I switched to Debian. So, now $HOME/perl5/lib/perl5 is the only lib in PERL5LIB.

    Once I got that done, I had to figure out where to move the site independent modules to.

    I moved the ones I use for my personal non-site scripts to $HOME/bin/files/lib. These are the reason I learned how to use FindBin. I know it is not the best place for them, but they are not pretty and are not even version controlled now.

    I moved the ones I want to share to $HOME/mods/lib where I can write tests and whatever else I need to learn.

    There are some duplicate modules in my site's lib dir as are in mods/lib, but that will change once I get those packaged and on CPAN.

    I thought some of you might be interested in these little changes in my coding practices; some have been arguing with me over them for a very long time. I hope that the changes I made are slight improvements. If you are interested in looking at what I have done in the past two months, you can see my site's and module's repositories. I am trying to stay excited about sharing, but it can be hard when I see just how much more I need to do to get these ready for it.

    Have a nice day everyone...

    I hope this was not too scattered.

    My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
PerlMonks Discussions
Title bar and menu face lift?
3 direct replies — Read more / Contribute
by Lady_Aleena
on Sep 08, 2020 at 17:27

    I played around with some new code for the top bar and the menu. I removed the tables and used flex. It isn't perfect, but it might be a slight improvement.

    Note:This, or something close to it, is what I originally posted. The code in the first one is different.

    My OS is Debian 10 (Buster); my perl versions are 5.28.1 local and 5.16.3 or 5.30.0 on web host depending on the shebang.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2020-09-13 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I don’t succeed, I …










    Results (97 votes). Check out past polls.

    Notices?