What does reading from <> do in Perl? For example, what will the following do?
print for(<>);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The so-called diamond operator (
<>) reads line-by-line (in scalar context) from STDIN or the filename(s) specified as command-line arguments.From
perldoc perlop:In list context,
<>returns all lines, with each line stored as an element in the list.This means that
print for <>;will do the same thing asprint while <>;, albeit with more memory.