Curious to know why you need to do that
Let's say I don't like the way that perl's print() function outputs non-zero NVs.
So I write an "alt"ernative "p"rint function (
palt()) that outputs non-zero NVs as I like to see them presented.
Then, whenever I want to print() a scalar, I need to keep track of whether that scalar is a non-zero NV, or whether it's something else.
If it's a non-zero NV, I certainly don't want to do
print($sv), and if it's a plain string or a reference to a module object, I certainly don't want to coerce it to an NV by doing
palt($sv).
It would be much better, IMO, if I could just use
palt() every time I wanted to print anything - and rely on it to provide the customized output for non-zero NVs, and also to provide the same output as
print for all other arguments.
And that's essentially what I've done.
Given that
print is rarely given bracketed arguments, it would be nice if
palt did the same.
But if that can't be done, then I just document that
palt should always be given bracketed argument(s) ... and move on.
It's not really a big deal ... just something I wanted to check on.
ikegami's solution looks fine to me - the only downside being that it doesn't port back to pre-5.36 perls, IIUC.
Cheers,
Rob