I've blogged a bit about my steps to get Net::Pcap to compile again - I won't paste the complete text here unless there is demand, but I'm posting the link to the article here :)
On August 21, 2021, famous Polish mathematician Andrzej Schinzel passed away at the age of 84. He was one of the great minds behind modern number theory. May he rest in peace. I have extended one of my CPAN modules relating to his work and dedicated the release to his memory.
One of the things the Perl 5 Porters work hard on is issuing diagnostics that are actually diagnostic. I think they do a pretty good job at this, but sometimes I need a bit more explanation than the typical one-line message.
Now, there is documentation on all of these in
perldiag, but paging through that looking for my message is a pain.
Fortunately, there is a module for that:
diagnostics. This module causes diagnostics to be expanded into their full explanation as it appears in
Typically you would not put a
use diagnostics; in your Perl code, though of course you could. Instead, you would load it via a command-line option to
perl, or maybe via environment variable
PERL5OPT. That is, either
$ perl -Mdiagnostics my-flaky-perl.PL
$ env PERL5OPT=-Mdiagnostics perl my-flaky-perl.PL
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on October 24, 2021 at 24:00). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Middle 3-digits
You are given an integer.
Write a script find out the middle 3-digits of the given integer, if possible otherwise throw sensible error.
Input: $n = 1234567 Output: 345
Input: $n = -123 Output: 123
Input: $n = 1 Output: too short
Number matching. Match syntax is similar as a switch syntax of C language.
Finally enjoying again ...
The month of September is very special to me personaly.
Well, I got married in the very same month 18 years ago. The best part is, I choose the day 11 to get married. I have never missed my wedding anniversary, thanks to all the TV news channel.
On the day, every year I find every TV news channel talk about 9/11 episode. It works like reminder to me.
Let's get back to the main topic ...
For the last few months, I have been late in making monthly report on time. This has created many problems for me. One of them and the most important is that I don't remember what I did last month. I then look back my activities on various social platforms that I am active on e.g. Facebook, Twitter and LinkedIn. It doesn't always help as I am not very active either socially these days.
BTW, I started working on this report around 6 am today.
So what's going on?
This warning was touched on in A Belated Introduction, but I thought it deserved its own entry.
When a Perl scalar comes into being, be it an actual scalar variable or an array or hash entry, its value is
undef. Now, the results of operating on an
undef value are perfectly well-defined: in a nuneric context it is
0, in a string context it is
'', and in a Boolean context it is false.
The thing is, if you actually operate on such a value, did you mean to do it, or did you forget to initialize something, or initialize the wrong thing, or operate on the wrong thing? Because of the latter possibilities Perl will warn about such operations if the
uninitialized warning is enabled.
If you really intended to do this,
no warnings 'uninitialized'; will suppress the error.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on October 17, 2021 at 23:59). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Pandigital Numbers
- Write a script to generate first 5 Pandigital Numbers in base 10.*
As per the https://en.wikipedia.org/wiki/Pandigital_number, it says:
A pandigital number is an integer that in a given base has among its significant digits each digit used in the base at least once.
Perl version 5.36. isa operator. try catch syntax. enable warnings. use v5.36. use v7. The introduction of the members of Perl core team.
Util::H2Ois an incredibly powerful tool for managing
HASHreferences in a more natural way.
This post is the first of several that will explore this awesome module. I've started using it quite a bit in both new code and in existing code. There are several imporant cases where it really shines. Here we explore the power it has to iteratively refine existing code. It's also fun and easy to introduce into existing code.
Util::H2Oprovides a method called
h2othat provides a very powerful way for turning a hash reference to an object . Generally speaking, this means I get accessors with as few keystrokes as possible.
I've been using this module quite a bit recently, and I really do like the improvements it has over the more traditional modules used for generating accessors.
The most basic use of
h2ois to provide accessors to a hash reference with a single level of keys. I tend to use hash references a lot .
Finally enjoying again ...
Ever since I joined Oleeo, I keep talking about it in every monthly report.
Well, right from day one, I have been getting to work on something I never worked on before. To be honest with you, I was expecting to fight with good old CGI ridden code mostly. I find myself lucky to have such a great supporting team. Right now I am playing with Elastic Search and I am enjoying it. Thanks to CPAN for such a cool library, Search::Elasticsearch.
Did you notice last monthly report was published on 22nd Aug?
I have never been so late ever since I started the series of monthly report.
You must be thinking, why bother with monthly report? Who cares what I do?
I agree, nobody cares. But I still do it every month since Nov 2018, my first monthly report was published on 2nd Nov 2018. In two months time, I would complete 3 years of monthly reporting. Honestly speaking, I didn't realise it until now.
This is my entry for
Task 1, "Disjoint Sets" was basically something I've done before somewhere else. In fact, what I'm using is overkill for just determining if two sets intersect. I imagine most people would probably use the FAQ answer. However, I'm a fan of what cardinal LanX of Perl Monks fame was trying to do in making set intersection a more "organic" operation. I don't know how much those ideas developed, however, so I'll be looking at the other solutions to see if there's anything new.
I actually did use my perlmonks code on real problem a few years ago, in modified form. It does the trick pretty quickly compared to other approaches. Thanks perl hashing!
You can find my code for Task #1 here.
Have you heard that they are finally putting together a proposal to add a clean modern OO system into the core of Perl?
It’s reassuring that the list of contributors to the proposed design includes some of the most highly respected names in the Perl community, many of whom have previously taken one (or more!) tilts at this particular object-oriented windmill.
Indeed, over the past two decades I too have repeatedly attempted to design and prototype richer and more robust OO systems for Perl, starting way back in the previous millennium with a brief stint as the maintainer of Class::Struct, and continuing on though the release of modules such as Class::Std, Class::Delegation, and most recently: Dios.
One of the changes to Perl that we're considering on p5p (the perl5-porters mailing list) is the removal of taint support. The first step towards that is to add a Configure option that lets you build a Perl without taint support.
In this post I'll explain what we're considering, and why. The purpose of this post is to let everyone beyond p5p know about this, and give you a chance to comment.
Since my last post I wanted to take my EV charge calculator script and convert it into a web form. In this post I breakdown how I migrated the script to a Dancer2 web app.
Just a minor note for those readers who may not be aware, Dancer2 is a "lightweight web-framework for Perl" as described in Dancer2 documentation and can be similar in comparison to Ruby Sinatra and Python Flask.
I started by creating a new project folder with the dancer2 program ( # please note that I am working on a Windows PC and on a linux OS the program would just be named dancer2 )
dancer2.bat -a EVCalc
I wrote a script to covert the electric rate csv file into a module and added all the calculation code in the main project module. All the html markup is stored in this template file and I sprinkled some CSS which renders a page similar to the screenshot below after submitting some data for calculating the charge of an EV :
Thank you for your time, I hope you enjoyed my post.
Again another week where I solve one answer and punt on another.
Well, "solve" may be a strong word for what I did with this problem, at least for my programming conscience. The problem statement was simple, but had no requirements for an acceptable solution other than what you could infer from the example solution in the problem statement. However I did give not one, but two solutions, so that's not totally lazy, even if each, on its own, is lazy, right?
On github at https://github.com/ronsavage/SQL you will find a repo of SQL stuff created by Jonathan Leffler.
I recently added some files for SQL 2003 and SQL 2016, created by Domingo Alvarez Duarte.
Specifically, look for:
I'd suggest downloading the *.xhtml files and viewing them locally, rather than hammering the on-line convertor mentioned in the readme files, which accepts *.ebnf files and displays these railroad diagrams.
And that begs the question: Is there any Perl code which converts a grammar into a railroad diagram?
It's very slow if you have more than a few thousand keys in memcached. Not an unusual use case I think? I've got a fix here, which appears to DTRT: https://rt.cpan.org/Ticket/Display.html?id=138133. Maybe? I didn't spend too long looking at memcached's low level wire protocol.
The patch passes all the module's current tests and works for us. It took our CPU load from being pegged at 75% all of the time to being idle. So, if you're using Cache::Memcached, and the ->stats method (which isn't in the XS version of the module) then you might want this patch.
On that note - who is maintaining Cache::Memcached? The last release was in 2012. This isn't a high river module, but any app of significant size or age is *probably* using it and if they're using the ->stats method then ... Sure there's the ::Fast version, but I suspect this version is in a lot of places.
So if you know someone who knows someone who can prod the current maintainers then please point them at this post/patch. If you're using Cache::Memcached then perhaps try out this patch as well.
Today I have wandered on the famous academic paper archive and suddenly a thought popped into my mind - use Perl as the keyword in searching.
Computer science papers with "Perl" in the title
Computer science papers with "Lisp" in the title
Computer science papers with "Ruby" in the title
Computer science papers with "Julia" in the title
https://arxiv.org/search/advanced?advanced=&terms-0-term=Julia&terms-0-field=title&classification-computer_science=y (53 ****)
For Haskell: ~50
For Java: ~249
For Python: ~357
For Perl Data Language (PDL): 0
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.