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

Ryan Erwin ryan at erwin.org
Thu Oct 14 15:52:07 CDT 1999


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.

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.

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).

Thanks!

ryan [ryan at erwin.org]


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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