perldoc perl5150delta
says:
$$ can be assigned to
$$ was made read‐only in Perl 5.8.0. But only sometimes: "local $$"
would make it writable again. Some CPAN modules were using "local $$"
or XS code to bypass the read‐only check, so there is no reason to keep
$$ read‐only. (This change also allowed a bug to be fixed while
maintaining backward compatibility.)
$$
is the current process ID, why in the world would you assign to it?
There are only a couple (literally) places in CPAN where people want to assign to $$
, and it's mostly for testing (I haven't understood IPC::Messaging
yet). I don't like this feature, especially since there's a much better way to get the same effect. The Perl 5 Porters added this feature because they could and they would rather not make the couple of cases do a better job of testing. If you read the p5p thread, it's obvious that this feature wasn't driven by need.
I wrote about it in Hide low-level details behind an interface.
However, I could be wrong on this because I'm not that good at the low-level black magic. I know there is a need to coordinate PIDs, but so far I think that $$
isn't the only way to do that. If someone has a use case that they can explain to me, I'll update that post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With