Mailing List Archive

surprisingly significant whitespace in v5.34.0 on WSL/Ubuntu
Is this intended or a bug?

$ perl -wle 'print ($_ -sqrt(4)) for 3'
print() on unopened filehandle 3 at -e line 1.

$ perl -wle 'print ($_ - sqrt(4)) for 3'
1


This is perl 5, version 34, subversion 0 (v5.34.0) built for
x86_64-linux-gnu-thread-multi
(with 60 registered patches, see perl -V for more detail)

--
"Lay off that whiskey, and let that cocaine be!" -- Johnny Cash
Re: surprisingly significant whitespace in v5.34.0 on WSL/Ubuntu [ In reply to ]
On Sat, Dec 30, 2023 at 10:57?AM David Nicol <davidnicol@gmail.com> wrote:

>
> Is this intended or a bug?
>
> $ perl -wle 'print ($_ -sqrt(4)) for 3'
> print() on unopened filehandle 3 at -e line 1.
>
> $ perl -wle 'print ($_ - sqrt(4)) for 3'
> 1
>
>
> This is perl 5, version 34, subversion 0 (v5.34.0) built for
> x86_64-linux-gnu-thread-multi
> (with 60 registered patches, see perl -V for more detail)
>

I doubt that it's intended, though I don't know whether it can be
classified as a bug. (It certainly doesn't DWIM).
On Windows, perl-5.39.5, I've reduced it a little to:

>perl -wle "$x = 3; print $x -2;"
print() on unopened filehandle 3 at -e line 1.

The best way I can think of demonstrating how (I think) this is being
parsed is to present this one-liner:

D:\>perl -wle "$x = 3; $y = -2; print $x $y;"
print() on unopened filehandle 3 at -e line 1.

It's an interesting one.
Both "print $x-2" and "print $x - 2" will DWIM.

Cheers,
Rob