The deprecated warning is a grab-bag. Basically, anything that is deprecated causes this warning to be generated, and the list changes from release to release.
The only reason I can think of ever to turn this off is around a deprecated construction while you are actively working to eliminate it. Silencing it and then forgetting about it will bite you, eventually.
For the curious (and to run my word count, since otherwise this would be a really short blog entry), the current list of deprecations according to the 5.34.0 perldiag is:
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.
Two friends, Foo and Bar gone on holidays separately to the same city. You are given their schedule i.e. start date and end date.
To keep the task simple, the date is in the form DD-MM and all dates belong to the same calendar year i.e. between 01-01 and 31-12. Also the year is non-leap year and both dates are inclusive.
Write a script to find out for the given schedule, how many days they spent together in the city, if at all.
Example 1
Input: Foo => SD: '12-01' ED: '20-01'
Bar => SD: '15-01' ED: '18-01'
Output: 4 days
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 perldiag.
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
Syntax::Keyword::Match is a module to enable match syntax in the current Perl by Paul Evans who is one of the current Perl Steering Councils. See perlgov about the Perl Steering Council.
Syntax::Keyword::Match Examples
Syntax::Keyword::Match Examples
Number matching
Number matching. Match syntax is similar as a switch syntax of C language.
The month of September is very special to me personaly.
Why?
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.
How?
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.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on Oct. 16, 2022 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: Zip List
You are given two lists @a and @b of same size.
Create a subroutine sub zip(@a, @b) that merges the two lists as shown in the example below.
Example:
Input: @a = qw/1 2 3/; @b = qw/a b c/;
Output: zip(@a, @b) should return qw/1 a 2 b 3 c/;
zip(@b, @a) should return qw/a 1 b 2 c 3/;
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.
Announcing here
Web::PageMeta
which is lazy build-ed HTTP-GET and web-scrape-data module able to work both in classic code and also to behave non-blocking in async code.
More info
on my blog
or
on CPAN
or
on GitHub
.
You are given MAC address in the form i.e. hhhh.hhhh.hhhh.
Write a script to convert the address in the form hh:hh:hh:hh:hh:hh.
Example 1:
Input: 1ac2.34f0.b1c2
Output: 1a:c2:34:f0:b1:c2
Example 2:
Input: abc1.20f1.345a
Output: ab:c1:20:f1:34:5a
MAC Address in Raku
This is done in a hurry, less than 45 minutes before the deadline. There might be a better or simpler way to solve this task, but using a couple of regexes is so simple that I don’t see any reason to try something else.
My blog post My Favorite Warnings: redundant and missing touched on the use of the if module. Comments on that post made me think it deserved a top-level treatment, expanding on (though not necessarily improving on) Aristotle's comment.
The if module is a way to conditionally load another module and call its import() or unimport() method. Sample usages are
use if CONDITION, MODULE, ...; # load and import
no if CONDITION, MODULE, ...; # load and unimport
In actual use the CONDITION is an expression that is evaluated at compile time. If that expression is true the named module will be loaded and its import() or unimport() method called with whatever arguments were specified. If the condition is false, nothing is done. If MODULE is a string literal it will have to be quoted, since as far as Perl is concerned it is just another argument.
Util::H2O
is an incredibly powerful tool for managing
HASH
references 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::H2O
provides a method called
h2o
that 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
h2o
is to provide accessors to a hash reference with a single level of keys. I tend to use hash references
a lot
.
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (on Oct. 2, 2022 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: Sequence Number
You are given list of strings in the format aa9999 i.e. first 2 characters can be anything ‘a-z’ followed by 4 digits ‘0-9’.
Write a script to replace the first two characters with sequence starting with ‘00’, ‘01’, ‘02’ etc.
Term::ReadLine is a core module (since Perl 5.002) that provides an extremely limited text interface of the prompt-and-type variety. Its main virtue is that you can add a back end which gives it things like command history, editing, and completion.
The back ends live in the Term::ReadLine::* name space, and you can control which one you get by defining the PERL_RL environment variable as documented at Term::ReadLine. If this is not defined, various undocumented things are tried; if none works you get the bundled minimal interface, Term::ReadLine::Stub.
The preferred back end (at least, according to Bundle::CPAN as of this writing) is Term::ReadLine::Perl. This is a shy, retiring module, with no POD documentation at all, which provides readline-style history, editing, and completion. By default the only completion you get is file name completion, but with some work you can expand this to do whatever you can figure out.
At this point, some words of caution are probably in order.
Ever since I joined Oleeo, I keep talking about it in every monthly report.
Why?
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.