Hi all. Trying out the Perl track for September and so far haven’t even got past Hello World.
When I try to run the test on my machine (macbook), I get a the message “Perl v5.38.0 required–this is only v5.30.3”. I’ve been poking at perlbrew and other options to get 5.38.0 installed on my machine (still in progress)…
I also just changed the directive in HelloWorld.pm to “use v5.30” and that worked.
Is 5.38.0 absolutely necessary? Or can I get by changing the exercises to 5.30 locally and not worry about the multi-version hassles?
I guess I’m not sure why 5.38.0 is required as it was officially released a couple of months ago.
5.38 is recommended, but not necessary. One of the features used throughout the track is signatures, which is marked as an experimental feature before Perl v5.36 (even though the functionality is unchanged many versions before that).
All the exercises can be completed on Perl as old as v5.20, but it may require more work on the user’s part to complete exercises in a Perl version that old.
The online test runner uses Perl 5.38, so even if a machine doesn’t have that version immediately available, the online test runner is still an available option.
I’m familiar with perlbrew but don’t use it much myself. Personally these days if I want to install different language versions I’ll use asdf.
I will look into correcting this documentation when I can. Unfortunately it has not seen any significant changes since 2019 and a few things have changed since then. I’ll see if I can take care of it sometime this week if not later tonight.
Kind of an old thread, but not really answered. If you have an older version of Perl, you can change the use line to reflect your installed version. e.g.
Change
use v5.38;
To
use v5.30;
This will remove the error. However, as mentioned, the Perl signatures cannot be used in their full form, which you will see in the next exercises. You can however, still use the older form of signatures. e.g.
Change:
sub do_stuff($what_to_do)
{
}
To
sub do_stuff($)
{
my $what_to_do = shift;
}
I am still using an older version myself (v5.32) Strawberry Perl on Windows 10 because I had a problem installing V5.38 and the perlTK modules which I was messing around with for something else.
This is not correct. What is being used here is a different feature called a prototype.
As mentioned previously, signatures are marked as experimental in older versions of Perl. If I’m not mistaken, their functionality has not changed since 5.24. They can be enabled using use experimental qw<signatures>;
I linked to the Perl feature documentation in one of my previous posts which explains how to enable the feature.
The ‘signatures’ feature
This enables syntax for declaring subroutine arguments as lexical variables. For example, for this subroutine:
sub foo ($left, $right) {
return $left + $right;
}
Calling foo(3, 7) will assign 3 into $left and 7 into $right.
This feature is available from Perl 5.20 onwards. From Perl 5.20 to 5.34, it was classed as experimental, and Perl emitted a warning for its usage, except when explicitly disabled.
As of Perl 5.36, use of this feature no longer triggers a warning, though the experimental::signatures warning category still exists (for compatibility with code that disables it). This feature is now considered stable, and is enabled automatically by use v5.36 (or higher).