I was just reading the secret pseudo-constants, namely the Space fleet constant
<=><=><=> Space fleet 0
This seems to be because the outer <=>
is doing something I don't understand. My question is why does
my $foo = <=>;
Set $foo
to =
? Other non-alphanumerics seem to work too,
my $foo = <=>;
my $foo = <->;
my $foo = </>;
But, alphanumerics don't...
my $foo = <a>;
Moreover, the perlsecret
pod is confusing to me,
Even though it looks like a sequence of three spaceship operators, only the middle ship is an actual spaceship. The two outer "spaceships" are actually calls to
glob("=")
.
It doesn't seem to be the case either, as I can't make sense as to why, glob("=")
would return =
, but glob("a")
would return undef
-- even if there is a file called a
in the current working directory.
What is Perl doing in both of these cases? I assume it's falling back to a literal if the thing inside the <>
isn't an alphanumeric -- is that behavior supported?
<=>
is sometimes interpreted as a uses ofglob
, and why<a>
isn't, which is the very question asked. (It's also the only one that explains why<<>
is interpreted as none of those.) – Hon