use strict; use warnings; our @linesEntered = (); our $prompt = "Enter text (Ctrl-D to quit): "; our $dePrompt = "\r" . " " x (length($prompt) + 2) . "\r"; while(1) { print $prompt; last if eof STDIN; chomp($_ = <STDIN>); push @linesEntered, $_; } print $dePrompt; foreach my $line (@linesEntered) { # Do something with the line. ... }
The script will keep prompting for lines until it gets an EOF on STDIN (Ctrl-D on *nix, Ctrl-Z on Windoze I think but I'm not sure and you'd want to change the prompt). The $dePrompt just erases the prompt to make things look tidy.
I hope this is of use.
Cheers,
JohnGG
In reply to Re: Getting Multiple inputs
by johngg
in thread Getting Multiple inputs
by gzayzay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |