By Ovid
on
May 22, 2022 11:12 AM
On github, I've released MooseX::Extreme.
It's based on years of experience being the lead designer of the Corinna project and trying to figure out how we can get a version of Moose which is safer and easier to use, including removing a lot of boilerplate. This code:
package My::Class {
use MooseX::Extreme;
... your code here
}
Is sort of the equivalent to:
These are some answers to the Week 165 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
This week, Task 1 and part of Task 2 relate to Scalable Vector Graphics (SVG). I’d been using SVG a very long time ago and certainly didn’t remember any of the details. So, in my first blog relating to PWC 165, I stated that I didn’t have time for that and covered only the part of the challenge not related to SVG. I also said that, in the event that I find some time over the weekend, I might come back and fulfill the SVG part. I thought at the time that this was rather unlikely, but I was finally able to cover the SVG part, at least in Raku.
Task 1: Scalable Vector Graphics (SVG)
Time::Piece
is a date/time module that replaces the built-in functions gmtime()
and localtime()
. The replaced functions return a Time::Piece
object, with accessors for the compontents of the time. Time::Piece
also provides formatting, parsing, and arithmetic.
This module has been in core since Perl 5.9.5. I was able to get it to pass
tests as far back as 5.8.1, though not 5.8.0 or 5.6.2.
Without this module, you would obtain the current Gregorian year in your local zone like this
my $year = ( localtime() )[5] + 1900;
or maybe
my ( undef, undef, undef, undef, undef, $year ) = localtime();
$year += 1900;
Neither is particularly self-documenting, and the latter is much more verbose than we expect of Perl.
Hello everybody,
after a long time of waiting it is finally time - we cordially invite you
to the German Perl/Raku Workshop 2023.
Next year's workshop will take place from Monday 28 February to
Wednesday 1. March in the Saalbau Gallus in Frankfurt am Main.
By Dean
on
April 20, 2022 4:13 PM

Reminder: Until April 30th you can get your conference ticket for the low price of $275 per person! Register now!
Don't miss out on booking accommodation at the venue as it is certain to sell out.
Please like the Conference on Facebook and follow it on Twitter
These are some answers to the Week 165 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a few of days from now (on May 22, 2022 at 24:00). This blog post offers some (partial) solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
The open or die
idiom is fairly ubiquitous in Perl. To be useful, the exception should say something about what went wrong: open ... or die "Open error: $!"
, for example.
The $!
built-in variable (a.k.a. $ERRNO
or $OS_ERROR
if use English;
is in effect) gives you access to the C language errno
variable, which through the magic of Perl interpolates an error message appropriate to the error given.
But there are times when some error analysis is in order. Fortunately, $!
is a dualvar
, so if you access it in numeric context rather than string context, you get the actual numeric value of the error code. But for both portability and maintainability you don't want to compare $!
to a numeric literal. Thus, Errno
. For example:
In which we pine for The Good Place,
while visiting The Bad Place.
I'm going to start this blog by writing a very simple guide on installing Perl using perlbrew.
To install Perl using perlbrew, first visit the website and grab its
curl -L https://install.perlbrew.pl | bash
and paste it in your terminal, and wait for it to do its job.
Now you will have to run
perlbrew init
to initialize perlbrew.
After that you will probably have to add it to your $PATH environment variable as the installation says after it is done downloading. This can be done with a command like
echo source ~/perl5/perlbrew/etc/bash >> ~/.bashrc
or
echo source ~/perl5/perlbrew/etc/bash >> ~/.zshrc
depending on your shell.
Once installed, you can see a list of different installable Perl versions by issuing the
perlbrew available
command.
At $work, one of my colleagues who is not in a developer role has started to get into writing code more and more, and I am mentoring him. He's about to work on a productive ticket with Moose for the first time, so I gave him a little reading list, mostly involving selected parts of the documentation as well as Ricardo Signes' excellent talk Moose is Perl.
But then I thought I must have read lots of great blog posts about Moose on the Perl Advent Calendar over the years. I tried to find a few, but had some trouble identifying them easily. So I wrote a quick scraper. Here are all articles that mention Moose since 2010 (where the format of the website changed). Most of them are about Moose or one of the numerous MooseX modules.
Perl has two operators, cmp
and <=>
, which are basically never seen outside of sort
blocks.
That doesn’t mean you can’t use them elsewhere, though. Certainly sort
and these operators were designed to work seamlessly together but there isn’t anything sort
-specific about the operators per se, and in some contexts they can be the most appropriate solution.
An example would be some code that used to go (almost exactly) like this:
my ( $maj, $min, $rel ) = split /[.]/, $version;
my $version_ok = $maj > 3 || (
$maj == 3 && ($min > 6 || (
$min == 6 && $rel >= 8
))
);
By Sergey
on
April 5, 2022 4:50 PM
Про перл по-русски маловато пишут, вот и будем по возможности наполнять знаниями
Just in case the problem passed you by, Rene "cavac" Schickbauer has a post discussing a Zlib CVE, and the implications for cpan modules:
I have done a casual grep through my local CPAN mirror (yay for local mirrors!), which has given me a list of potentially vulnerable modules. There are over 90 of them. Yes, there are probably a few false negatives and a few false positive, as i didn't have time to go over each distribution in detail.
Please check your CPAN distributions for any use of zlib.c, libz.c, deflate.c, compress.c and similar variants and update as necessary. If at all possible, i would also recommend to switch to either the zlib provided by the operating system or at least coordinate with other CPAN authors to reduce the number of static copies of the zlib libraries spread all over CPAN modules.
I've been using perlimports a lot at $work. I'm generally quite happy with perlimports, but it can get confused by modules which are being dynamically used. Fortunately, there's one little trick that can help in this scenario.
Read the full article.
By Dean
on
March 25, 2022 3:56 PM
Anyone using DBD::Oracle is invited to test out out this dev release v1.90_1
Download from metacpan here
GH Tag here
v1.90 candidate branch
This
commit
is a big big change which should hopefully fix a lot of problems
For several years, I spent much time writing code for the Raspberry Pi, including hardware level register C code so that we can use various Integrated Circuit chips and sensors with Perl.
A couple of years ago, I acquired much larger and much more expensive toy, an all-wheel drive, full auto-pilot Tesla Model-X SUV, so of course, I want to write Perl code to access and manipulate it.
In the ensuing two years, I developed several microcontroller-based devices for the car, including one that knows where the car is, and its battery charge and state, and dispslays this information via an LED light strip and an OLED screen inside of my garage, along with an audible alarm that sounds for 1/8th of a second every three seconds if the battery is below a certain threshold so I don't forget to plug the charger in.
Dancer2 0.400000 has been released, and is on its way to CPAN.
We realize that some of you might be curious as to the large version bump. There are a couple of reasons for this:
* Modules we depend on bumped their minimum Perl version to 5.12, requiring us to follow suit.
* As of 2022, Dancer2 has an official deprecation policy. We are implementing this policy effective with this release, and it will help shape and guide future development.
* We've officially marked a lot of outdated and unused API as being deprecated.
With that, the following APIs, methods, etc. are now officially deprecated:
Dancer2::Test
request->dispatch_path
push_header
header
headers
context
- Named placeholders:
splat
and capture
In plugins:
* plugin_setting
* dancer_app
* request
* var
* hook
To discuss any of these, you can find issue for each of the above here.
In which we reach the first plateau of clever, then (unfortunately) stop climbing.
(Still editing)
By Saif
on
March 9, 2022 5:27 PM
As a bystander in the evolution of Object-Oriented Programming in Perl,
and someone who is really only just starting to get the hang of Perl modules and packages
(still not any good at it), I get really quite overwhelmed by ideologies.
There is considerable debate about the right way to program things, the right
style, the right direction that Perl should go. It is Vim vs Emacs, Atari ST
vs Amiga, Mods vs Punks. Really one needs a language to do what one needs it
to do, simply, quickly and consistently. For an amateur, Perl has been able
to do exactly that for me. I code rubbishly, but hey, who's looking?
Last year, impressed with the apparent speed of an M1 Mac Mini I bought to try out, I explored its perl performance and wrote about it in a
blog post
. I used mainly my own benchmarks which were mostly representative of workloads I was interested in.