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...
That's what $_ is; a global; and it's exactly what the real say does, along with a raft of other built-ins.
But it's a read-only reference, so it cannot harm anything.
So the question is, is that $_ referenced in the say() sub a global from the implicit $_ in the mainline loop, or not...?
I cannot parse the highlighted bit of that sentence.
Perhaps this will satisfy: There is only one $_ at any given time. It is the global $_.
Sometimes it is localised implicitely by some constructs (eg. for, while) and sometimes explicitly by user code; but all that means is that a copy of the previous value is kept somewhere and gets restored once the localisation ends.
Whenever you use $_; you get its current value, regardless of whether it has been localised in one or many previous scopes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reliably simulating 5.10 say()
by hlc (Initiate) on Feb 08, 2015 at 15:06 UTC |