in reply to Forcing array context on a file handle
"$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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Forcing array context on a file handle
by tobyink (Canon) on Oct 30, 2012 at 21:07 UTC | |
|
Re^2: Forcing array context on a file handle
by ronmrdechai (Novice) on Oct 30, 2012 at 21:33 UTC | |
by Lotus1 (Vicar) on Oct 31, 2012 at 02:12 UTC |