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

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

From:
Tony Cook via RT
Date:
June 11, 2019 06:55
Subject:
[perl #133850] "Scalar found where operator expected" on printing toindirect filehandle within s///e
Message ID:
rt-4.0.24-25864-1560236125-884.133850-15-0@perl.org
On Tue, 28 May 2019 22:08:50 -0700, tonyc wrote:
> 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.

Applied as eec88220688fefa843e3f46b6b454fe090ee7568 through 82de236bf4d8d37736218318628cc3f85c53ab28.

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