Skip Menu |
Update: The bug tracker service is no longer shutting down.

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

Report information
The Basics
Id: 96037
Status: open
Priority: 0/
Queue: IO-Prompt

Owner: Nobody in particular
Requestors: bitshag [...]

Bug Information
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 [...]
From: Erik Lyons <bitshag [...]>
Download (untitled) / with headers
text/plain 625b
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: [ #96037] possible bug
Date: Fri, 30 May 2014 05:34:26 +1000
To: bug-IO-Prompt [...]
From: Damian Conway <damian [...]>
Download (untitled) / with headers
text/plain 739b
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 is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to