- Subs are at the bottom. This is bad habit, as this will make your programs share all file scoped lexicals. Some people know the dangers and still put subs at the bottom, which is their own problem. Tutorials should not have subs at the bottom, but near the top.
- Strict is mentioned somewhere near the end. This is awful. Imho, all examples in a tutorial should be strict-compliant, as you will only disappoint people by not making sure they are.
- ⊂ is used. This is very, very bad, as this implicitly passes @_. If you know what it does, go ahead and use it. Do not use it by default. This is not explained in the tutorial. It even says:
Subroutines are usually called by prefixing their name with an ampersand, that is one of these -- & , like so &print_results; . It used to be cool to omit the & prefix but all perl hackers are now encouraged to use it to avoid ambiguity. Ambiguity can hurt you if you don't avoid it.
WHAT?! Please, learn some Perl 5 before writing a Perl 5 tutorial, Robert Pepper.
- The list of comparison operators does not include <=> and cmp. The list is incomplete.
- chop is being used. It is bad, and its use should not ever be encouraged. chomp is mentioned, but chop comes first, which is the wrong order, imho.
- C-style for is being used where iterating over the array elements themselves would be a lot better. The author knows this, but uses C-style for nevertheless. If he really wanted to show how it works, his explanation should be more detailed, and a non-array should be used.
- "$_" is used where $_ is enough.
- ^$ are said to match begin and end of the string, while they match begin and end of the line, and their semantics can be changed with /m.
-
If you want to negate the entire regex change =~ to !~ (Remember ! means 'not equal to'.)
That is not true. != and ne mean 'not equal to'. ! only negates in a boolean fashion. It is the "not" operator in short form.
- As alternative delimiters, #s are being used. This is a bad idea, because this way, you will have problems when using /x with comments, and it looks odd.
- \1 is used instead of $1 in the RHS of substitutions. This works, but should be considered a bad feature. perlre covers this. Has the author never read the documentation?
- srand is being used. Do not use srand, unless you REALLY know what you are doing. This is covered in perlfunc and should be common knowledge. Perl 5 programs should not use srand. Is this an upgraded Perl 4 tutorial?
- Filehandles are not explicitly closed. This is a problem. flock is not discussed. This is a big problem.
- $^I is being used _before_ -i is mentioned. Bad.
- The heredoc example has no quotes around the ending keyword. This is not wrong, just bad style.
- system's multiple-argument form is not discussed. People will get bitten by variable interpolation sooner or later.
- A module is created without a package. Exporter isn't even mentioned. I would not call this a module. A function library, perhaps. Reading perlmod was too hard, I guess.
- CPAN is mentioned, but only twice and no examples of available modules are given. CPAN is one of the most important features Perl offers.
- $MAIN::name is used. The default package is not MAIN. It is main. This should be known.
This is just a few of all mistakes/errors, as I only skimmed the surface. I think it wouldn't be hard to find more.
I will try contacting the author and send him a link to this rant. update: netcat.co.uk does not exist. I was unable to contact the author.
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.