June 2022 Archives

Smart Match in CPAN

There is nothing like looking, if you want to find something. -- The Hobbit, iv, "Over Hill and Under Hill"

Recently on the p5p mailing list the topic of removing smart match re-surfaced. There was a fairly vigorous discussion about the effect this would have on CPAN. So I thought I would look into how many uses there actually were.

Fortunately there are Perl Critic policies for this: Jan Holčapek's Perl::Critic::Policy::ControlStructures::ProhibitSwitch…

Annotated Perl::Critic Policy Index

In the wake of my postings on the file access tests (-r and friends) I wondered if there was a Perl::Critic policy to find them. So I constructed an annotated index of Perl Critic policies. Because of its size I stuck it on GitHub rather than in-line to this blog post.

This index assumes that any CPAN module whose name begins with Perl::Critic::Policy:: is a Perl…

My Favorite Modules: File::stat

File::stat overrides the core stat() and lstat() functions. Instead of arrays, the new functions return an object having methods corresponding to the elements of the arrays returned by the original functions. This module has been in core since Perl 5.004.

The advantage of this module is clearer code. For example, to get the size of file $file without it is something like

    my $size = ( stat $f…

Core Modules: filetest

The filetest pragma modifies the behavior of the file test operators (a.k.a. the -X operators.) It has been in core since Perl 5.6.0.

As of Perl 5.36.0 it still has only one sub-pragma, 'access', which applies to the -r, -w, -x, -R, /users/tom_wyant/2022/06/index.html

The File Access Operators: To Use, or Not to Use

The file access operators are, for the purpose of this blog entry, the file test operators -r, -w, -x, -R, -W, and -X. The upper case operators test the ability of the user's real UID to read, write, or execute the file being tested. The lower case operators do the same for the user's effective UID.

Though Perl provides these, th…

About Tom Wyant

user-pic I blog about Perl.