Dave Cross

Authored Comments

I agree that ampersands are a matter of preference. But you use an ampersand in one example - &sum(1,2) - and not in another - roller($sides). It's an inconsistency that you don't explain, so it will just be confusing to newcomers to the language. They will try to work out the reason for the change ("Oh, maybe you need to use '&' if you're passing the return value to print()") and will get it wrong.

If you're going to use an ampersand then please be consistent about it. Alternatively, explain to your readers how you decide whether to use one or not.

The same is true with your use of "use utf8". It's in one of your full programs, but not the other. And because you don't mention it, your readers will be confused as to when they should use it.

When writing tutorials (and, particularly, tutorials aimed at beginners) simplicity and consistency should be your watchwords. Any necessary inconsistencies should be clearly explained and any unnecessary inconsistencies should be removed.

You may be interested in my Perl tutorial for absolute beginners - https://perlhacks.com/perl-taster/

If you're going to write an article called "Learn Perl in 2022" then you could include some Perl that looks like it was written in the last five years.

You should be using "say()" instead of "print()" in most of your examples.

You don't explain why you use an ampersand when calling "sum()", but not when calling "roller()" - the answer is that an ampersand isn't needed in either case and using it only serves to confuse people (see https://perlhacks.com/2015/04/subroutines-and-ampersands/ for more details).

Oh, and having "use utf8" in your example programs is achieving nothing useful. The "utf8" pragma tells the Perl compiler that your source code includes characters that are encoded as UTF8. All of your code just uses ASCII characters - so that's just adding unnecessary complexity.