(This is my first meditation. I am posting in hopes it will help someone down the line! I can't find another node about this, but that doesn't mean there isn't one :) .)
I needed to run a program and then wait for the user to hit Enter. I tried this:
Not what I expected!$ perl -e 'system(@ARGV); readline' echo foo foo Can't open echo: No such file or directory at -e line 1. Can't open foo: No such file or directory at -e line 1.
After all, perlrun says that:
If -e is given, Perl will not look for a filename in the argument list.
What I was missing is that readline does look at the argument list. Readline:
reads ...from *ARGV if EXPR is not provided
So what I needed was to expressly read from STDIN to get my keypress:
# vvvvv $ perl -e 'system(@ARGV); readline STDIN' echo foo foo (<=== waited here for me to press Enter)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console
by choroba (Cardinal) on Nov 30, 2020 at 16:47 UTC | |
|
Re: A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console
by haukex (Archbishop) on Nov 30, 2020 at 16:50 UTC | |
|
Re: A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console (perl -MO=Deparse)
by Anonymous Monk on Dec 01, 2020 at 00:27 UTC | |
|
Re: A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console
by Anonymous Monk on Nov 30, 2020 at 19:43 UTC | |
by cxw (Scribe) on Dec 01, 2020 at 14:13 UTC |