in reply to First time using Args
You want to explicitly read from STDIN, not the magical ARGV, which only reads from STDIN if no argument are given (or to be precise, if @ARGV is empty). Replace your <> with <STDIN>.
And as a general advice: avoid write tools that ask the user questions: arguments are more flexible, as it makes piping and scripting easier. Imagine that each time you would run perl from the command line, it starts with:
$ perl Do you want to enable warnings? [y/N] n Do you want to loop over the input? [y/N] y You want to loop over the input. Print $_ each time? [y/N] ... 40 questions later ... Please type your one-liner, ending with a newline
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: First time using Args
by mmusser (Initiate) on May 03, 2012 at 17:34 UTC | |
by JavaFan (Canon) on May 03, 2012 at 17:57 UTC |
In Section
Seekers of Perl Wisdom