SPUG: Multiple uses of <STDIN> in a script?
charles.e.derykus at boeing.com
charles.e.derykus at boeing.com
Fri Oct 15 15:09:57 CDT 1999
> my @rray = <STDIN>;
> chomp (@rray);
> foreach (@rray) {
> print "this line is $_: [Y:N] ";
> my $y_or_n = <STDIN>;
> chomp ($y_or_n);
> print "$y_or_n just for the heck of it...\n";
> }
> I would run the script (i'll call it /tmp/test.pl) like this:
> find /tmp | /tmp/test.pl
Another alternative if the file count doesn't overflow
the command line buffer:
for file in `find /tmp`; do
/tmp/test.pl $file
done
and wrap the perl with a loop which shifts off the
command line:
while ( defined(my $file = shift) ) {
my @rray = <STDIN>:
...
}
Still another disadvantage is that the shell loop blocks until
the backticks are done.
If those drawbacks are too much, you might just
consider letting Perl find the files internally.
Rgds,
--
Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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