July 2022 Archives

Numeric Variable Names With Leading Zeroes

Over on the p5p mailing list, a user raised the issue that use of variable $00 is an error starting with Perl 5.32, and asked that this "regression" be fixed.

I have always understood that variables whose names begin with anything but an alphabetic or an underscore are reserved to Perl, and you mess with them at your peril. And this is the gist of the Porters' response to the post. Recent versions of ="…

Sorting Subroutine Results

The Perl sort built-in is mostly (at least by me) called as sort LIST or sort BLOCK LIST. But there is a third way to call it: sort SUBROUTINE LIST, which actually appears first in the documentation.

This is not a blog entry about using the sort SUBROUTINE LIST form of sort. It is more about the need to be aware of this form when writing…

Scalar Context: Lists Versus Arrays

For a long time after I first encountered Perl, I looked on "list" and "array" as essentially interchangeable concepts. A list was simply the source construct corresponding to an array. This idea is mostly correct. But as they say, the devil is in the details.

One of the differences is what happens to them in scalar context. An array evaluates to the number of elements it contains. A list evaluates to its last element. So:

my @array = qw{ one two five };
say scalar @array;  # prints '3'
    no warnings 'void'; # Note the need for this
    say scalar( qw{ …

Announcing perlcritic Policy ValuesAndExpressions::ProhibitFiletest_rwxRWX

Since several places in the Perl documentation caution against the use of the file access operators (-r and friends), and since I was unable to find a Perl::Critic policy dealing with this, I thought I would make one: Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_rwxRWX.

This policy is assigned to the ="pr…

About Tom Wyant

user-pic I blog about Perl.