develooper Front page | perl.perl5.porters | Postings from May 2019

[perl #133850] "Scalar found where operator expected" on printing toindirect filehandle within s///e

From:
Tony Cook via RT
Date:
May 29, 2019 05:09
Subject:
[perl #133850] "Scalar found where operator expected" on printing toindirect filehandle within s///e
Message ID:
rt-4.0.24-22756-1559106530-516.133850-15-0@perl.org
On Mon, 18 Feb 2019 20:44:26 -0800, tonyc wrote:
> On Fri, 15 Feb 2019 11:37:16 -0800, corion@corion.net wrote:
> > last week I (together with E. Choroba) stumbled on a weird syntax
> > error (Windows shell quoting):
> >
> > perl -wle "s/(.*)/print $fh $1/e"
> >
> > This surprisingly gives a syntax error, yet still seems to run the
> > code:
> >
> > Scalar found where operator expected at -e line 1, near "$fh $1"
> >         (Missing operator before $1?)
> 
> This isn't a syntax error, but a warning (but still buggy).
> 
> The code inside the replacement part of s///e is handled with a
> sublex, and the code that decides whether an operator or term is
> expected after C<print $fh> is mostly skipped for a sublex.
> 
> The attached fixes that, doing the same checks for C<print $fh> in a
> sublex within brackets as for a normal parse.
> 
> This fixes the same problem for C<< "... ${code} ..." >>.

Rebased on blead, and fixes for the related issues.

I'll apply this in a few days.

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133850



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About