in reply to Getting Multiple inputs
Another solution is to use a loop and push the words into an array as you get them. The user enters a blank line to stop entering words. This had the advantage that the user can input complete phrases.
use strict; use warnings; my @words; my $i = 1; while (1) { print "Enter word $i: >> "; $i++; chomp (my $word = <>); last unless length $word; push @words, $word; } print join(",", @words);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting Multiple inputs
by Anonymous Monk on Apr 05, 2006 at 18:59 UTC |