"$lines = @{[ (<$file>) ]}".The problem is that the former doesn't work, and the latter gives $lines = 1.Your 2nd example gives me the correct number of lines (not 1):
use warnings; use strict; open my $file, '<', $0; my $lines = @{[ (<$file>) ]}; print "$lines\n";
The output for me is 5.
In reply to Re: Forcing array context on a file handle
by toolic
in thread Forcing array context on a file handle
by ronmrdechai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |