[wplug] perl/unix question

bpmedley at 4321.tv bpmedley at 4321.tv
Wed Aug 1 20:36:18 EDT 2001


Hi,

I have a perl / unix question.  It has to do with getting input from the
user.  Below is what I want:

Situation: Running perl script w/o piping data to it

- If the user starts the program with no file list then they are prompted
  for input.
- If the user passes in a file list, that does not contain '-', then they
  are not prompted for input.
- If the user passes in a file list, that does contain '-', then they are
  prompted only when '-' is open.

Situation: Running perl script when piping data to it

- This should never prompt.

Below are examples:

./script.pl
always prompt

./script.pl file -
no prompting when parsing 'file'
prompt when parsing '-'

./script.pl file
never prompt

echo input | ./script.pl
never prompt

echo input | ./script.pl file -
never prompt

Based on my (probably incomplete tests) I have a script that does that.
However, it is IMHO, a less than ideal setup.  I am curious if anyone can
come up w/ a better version that what I've got.  I have attached my
version.

~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-., \|/  (___)  \|/ _,.-=~'`^`
                          Brian Medley         @~./'O o`\.~@
"Knowledge is Power" brian.medley at verizon.net /__( \___/ )__\  *PPPFFBT!*
  -- Francis Bacon                               `\__`U_/'
 _,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~= <____|'  ^^`'~=-.,__,.-=
~`'^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-==--^'~=-.,__,.-=~'`^`




More information about the wplug mailing list