This queue is for tickets about the IO-Prompt CPAN distribution.

Report information
The Basics
Id:
96037
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
bitshag [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



Subject: possible bug
Date: Wed, 28 May 2014 10:14:59 -0700
To: bug-io-prompt@rt.cpan.org
From: Erik Lyons <bitshag@gmail.com>
If my script is called with an argument, @ARGV is in turn used by the IO::Prompt module when called, and it barfs. I worked around this with a pop(@ARGV) before issuing prompt(), which works great because i'm only using one arg. Never had to do that before. Yet i'm really surprised no-one else has encountered it.

Not sure if this is a bug or just an exposure of my limited Perl knowledge. Maybe there's a best-practice method of "localizing" @ARGV which i've neglected all these years?

CentOS 6.5 up to date with built-in Perl.

e.l.

"It's like a koala bear crapped a rainbow in my brain."
- Captain Hazel "Hank" Murphy


Subject: Re: [rt.cpan.org #96037] possible bug
Date: Fri, 30 May 2014 05:34:26 +1000
To: bug-IO-Prompt@rt.cpan.org
From: Damian Conway <damian@conway.org>
Hi Erik, This is not a bug. It's a standard behaviour of Perl itself. prompt() uses the *ARGV filehandle (the same one that readline() and <> use). Perl's special behaviour is that, if @ARGV contains a value when a readline() is performed, that value is used as the name of a file, which is opened into *ARGV. This behaviour is described in detail in the perlop manpage, under "I/O Operators". Because prompt() acts like readline(), if your @ARGV contains any value when prompt() is called, it's used as the name of a file to read from. The workaround is either to clear @ARGV before reading, or else to localize @ARGV while reading, or to use the -tty option to prompt(): my $input = prompt -tty, '> '; Hope this helps, Damian


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.