in reply to Re^2: Reliably simulating 5.10 say()
in thread Reliably simulating 5.10 say()
But it leaves me worried that $_ is being used in say() as a global...
You can't "use as a global", you can just "use a global", and you're the one who asked to use $_.
So the question is, is that $_ referenced in the say() sub a global from the implicit $_ in the mainline loop, or not...?
Yes, because $_ is a global. Actually, it's a "super global", meaning "$_" refers to the same variable ($::_) no matter which package you're in.
Note: It is possible to make $_ a lexical, but that feature was also introduced in 5.10, it's experimental, and I don't think it will survive. (A step was already taken by core to avoid using it.)
So what you get is:
BEGIN { if ($] < 5.010) { *say = sub { local $\ = "\n"; print @_ ? @_ : $_ }; } else { require feature; feature->import('say'); } }
There's probably a module that does that.
|
|---|