Kelly Jones wrote:
perl -le '$x=<STDIN>; print $x'
hello <- I TYPED THIS IN AND HIT RETURN
hello

perl -le 'my($x)=<STDIN>; print $x'
hello <- I TYPED THIS IN AND HIT RETURN
[no answer, hangs forever]

$x=<STDIN> is in scalar context so only one line is read.

($x)=<STDIN> is in list context so readline keeps reading util the end-of-file is reached. To signal end-of-file in Unix/Linux type Ctrl-D or in DOS/Windows type Ctrl-Z.



John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to