Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Limited Number of User Input

by kash650 (Novice)
on Mar 21, 2013 at 23:36 UTC ( #1024840=note: print w/replies, xml ) Need Help??

in reply to Limited Number of User Input

EDIT: found out how to do this, using

while (my $text = <STDIN>) { chomp($text); print "You entered '$text'\n"; last if ($text eq ''); }

but with a counter instead of "last"

Replies are listed 'Best First'.
Re^2: Limited Number of User Input
by rjt (Deacon) on Mar 22, 2013 at 00:22 UTC

    Yes, good. May I ask, why do you ask the user to enter the number of files first when you already know the simple, intuitive (and very commonly used) way like this for the user to indicate they're finished? If you need to know how many files they entered, you can do something like this:

    while (<STDIN>) { chomp; last if $_ eq ''; push @files, $_; } printf "You entered %d files: { %s }\n", scalar @files, join(' ', @fil +es);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024840]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2016-10-25 11:34 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (317 votes). Check out past polls.