Muttley@DastartdlyHQ.org ignorantly rambled:
On Thu, 10 Oct 2024 16:09:49 +0100
Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
Muttley@DastartdlyHQ.org writes:
Its syntax is also a horrific mess.
>
Which means precisely what?
>
Far too much pointless punctuation. An interpreter shouldn't need the vartype
signified by $ or @ once its defined, it should already know.
For the purpose of variable declaration, how's the interpeter going to
know the type of a variable without being told about it? Obviously, not
at all.
Perl has three builtin types, scalars, arrays and hashes and
each is denoted by a single-letter prefix which effectively creates
three different variable namespaces, one for each type. That's often
convenient, because the same name can be reused for a variable of a
different type, eg:
my ($data, @data, %data);
$data = rand(128);
@data = ($data, $data + 1);
%data = map { $_, 15 } @data;
it's also convenient to type and easy to read due to being concise.
Outside of declarations, $ and @ really denote access modes/ contexts,
with $ standing for "a thing" and @ for "a number of things", eg
$a[0]
is the first element of the array @a and
@a[-3 .. -1]
is a list composed of the three last elements of @a.
And then there are semantically meaningful underscores (seriously?)
Similar to the number writing convention in English: 1,600,700, numbers
in Perl can be annotated with _-separators to make them easier to
read. Eg, all of these are identical
1_600_700
16_007_00
1_6_0_0_7_0_0_
But the underscores have no meaning in here.
and random hacky keywords such as <STDIN>.
<STDIN> isn't a keyword. STDIN is the name of a glob (symbol table
entry) in the symbol table of the package main. It's most prominent use
is (as they name may suggest) to provide access to "the standard input
stream".
<> is an I/O operator. It's operand must be a file handle, ie, either
the name of glob with a file handle associated with it like STDIN or a
scalar variable used to hold a file handle. In scalar context, it reads
and returns the next line read from this file handle. In list context,
it returns all lines in the file.
Eg, this a poor man's implementation of cat:
perl -e 'open($fh, $_) and print <$fh> for @ARGV'
I could go on.
Please don't enumerate everything else on this planet you also don't
really understand as that's probably going to become a huge list. ;-)