in reply to How do I read just one line of input

my ($line) = ... puts the right-hand side into list context. In list context, the <> operator reads all lines in the file/stream.

In scalar context, only the first line is read, so change that to

my $line = <STDIN>;

Replies are listed 'Best First'.
Re^2: How do I read just one line of input
by prasaduco (Initiate) on Jul 15, 2011 at 14:37 UTC

    Thanks Moritz, it worked :)