develooper Front page | perl.perl5.porters | Postings from December 2016

[perl #130076] readline argument list is messed up

Thread Next
From:
James E Keenan via RT
Date:
December 31, 2016 15:21
Subject:
[perl #130076] readline argument list is messed up
Message ID:
rt-4.0.24-20883-1483197697-671.130076-15-0@perl.org
On Sat, 12 Nov 2016 15:13:51 GMT, mauke- wrote:
> 
> This is a bug report for perl from l.mai@web.de,
> generated with the help of perlbug 1.40 running under perl 5.24.0.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> $ perl -wE 'say prototype "CORE::readline"'
> ;*
> 
> readline claims to take a single (optional) scalar argument.
> 
> $ perl -wE 'sub foo (;*); foo("a", "b", "c")'
> Too many arguments for main::foo at -e line 1, near ""c")
> "
> Execution of -e aborted due to compilation errors.
> 
> This is what happens when you use the same prototype on a sub.
> 
> $ perl -wE 'say readline("a", "b", "c")'
> readline() on unopened filehandle at -e line 1.
> ab
> 
> This is what happens when you try it with readline: Only the last
> argument is
> used; the rest leak through to say. No error is reported.
> 
> $ perl -wE 'say readline(1 .. 10)'
> readline() on unopened filehandle 10 at -e line 1.
> 123456789
> 
> Despite what the prototype claims, the argument is evaluated in list
> context.
> 
> $ perl -wE 'say "foo", "bar", readline(())'
> readline() on unopened filehandle at -e line 1.
> foo
> 
> If you call it with an empty list, it steals arguments from the
> surrounding
> context (it tries to read from "bar").
> 

Is this problem similar to that reported by sprout in https://rt.perl.org/Ticket/Display.html?id=93992?

-- 
James E Keenan (jkeenan@cpan.org)

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

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