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

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

Thread Next
From:
Tony Cook via RT
Date:
February 19, 2019 05:32
Subject:
[perl #133850] "Scalar found where operator expected" on printing toindirect filehandle within s///e
Message ID:
rt-4.0.24-16320-1550554368-452.133850-15-0@perl.org
On Mon, 18 Feb 2019 20:44:26 -0800, tonyc wrote:
> This fixes the same problem for C<< "... ${code} ..." >>.

There's some other similar cases - i.e. where PL_lex_state is checked for LEX_NORMAL but no other checks are made.  The simplest I was able to reproduce was:

 $  ./perl -we '%x = qw(a b c d); $_ = ""; $_ = @x {a}'
 Scalar value @x{"a"} better written as $x{"a"} at -e line 1.
 $ ./perl -we '%x = qw(a b c d); $_ = ""; s/^/ @x {a} /e'
 (no warning)

Kind of unlikely:

 tony@mars:.../git/perl$ ./perl -Ilib -we '{ my $x : shared = 1; }'
 tony@mars:.../git/perl$ ./perl -Ilib -we '$_ = ""; s/^/ { my $x : shared = 1; } /e'
 Unquoted string "shared" may clash with future reserved word at -e line 1.
 syntax error at -e line 1, near "$x :"

Another:

 $ ./perl -we '$a = ${time}'
 Ambiguous use of ${time} resolved to $time at -e line 1.
 Name "main::time" used only once: possible typo at -e line 1.
 $ ./perl -we '$_ = ""; s/^/ ${time} /e'
 Name "main::time" used only once: possible typo at -e line 1.
 Use of uninitialized value $time in substitution (s///) at -e line 1.
 (no ambiguous warning)

Tony

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

Thread Next


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