SPUG: Multiple uses of <STDIN> in a script?

Jim Traugott jtraug at seanet.com
Thu Oct 14 16:49:51 CDT 1999

>>>>> "Ryan" == Ryan Erwin <ryan at erwin.org> writes:

    > I hate to interrupt our fun discussion on where we are going to have our meetings but i ran into a little problem yesterday and wondered if one of you know the answer. ;) <- what do ya think of that guy...
    > Anyways:
    > i have a little command line script on my linux box that takes a list of file names on <STDIN>, then asks the user (me) a question about the file.  Usually, to get user input I just use my $somevar = <STDIN>; but it doesn't work in this case.

Could it be buffered? 
$f = select STDIN;
$| = 1;
select $fh;

    > i hunted around last night and found that perlfaq8 had a section called "Why can't my script read from STDIN after I gave it EOF?"  This sounds exactally like what is happening so I read on and the faq8 said "the POSIX module defines clearerr() that you can use."  So I checked the POSIX mod docs and it says:
    > clearerr - use IO::Handle::clearerr() instead.
    > Now, I go over and check IO::Handle docs and find that I'm supposed to issue:
    > $fh->clearerr
    > I do this (STDIN->clearerr) and it works just find, but I still can't prompt the user for something on STDIN.

You want to prompt the user on STDOUT.

    > The faq8 says that this is the technically correct way to reset the err flag so I would like to use it.  Besides, seek on STDIN just seems strange to me (if it would even work, i haven't tried).

Good Luck!


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list