3 ms·
The line f/1;#/+ is parsed differently depending on the day. On Friday it's [ "f", "/1;#/", "+" ] Other days it's parsed as [ "f", "/", "1", ";" ]. Perl
by trissylegs 5y ago
The line
f/1;#/+
is parsed differently depending on the day. On Friday it's [ "f", "/1;#/", "+" ]
Other days it's parsed as [ "f", "/", "1", ";" ].
Perl is parsing /1;#/ is a regex based on whether f takes arguments. Otherwise it parses the slash as division and then the hash is a comment.
Another example could be:
foo() {
some_func / 1;#/; die "It died"
foo
}
Which depends on some_func to not halt. some_func could come from another file, set by whoever invokes the current file. Whatever, it's determed at runtime.
This leads to a proof that perl is a actually impossible to parse.
https://www.perlmonks.org/?node_id=663393 https://www.perlmonks.org/?node_id=663393
Which means you can't do a lot of static tooling on perl because you just can't analyses the source accurately. (Compared to say python, which parses source before running it)