in reply to Re: Forcing array context on a file handle
in thread Forcing array context on a file handle

Hi, ronmrdechai

$lines = grep {$_} <$file>;

Replies are listed 'Best First'.
Re^3: Forcing array context on a file handle
by QM (Parson) on Nov 02, 2012 at 12:31 UTC
    That works for files in the default case, because every line will have a newline or somesuch, and will not be an empty string. For counting, map would be more appropriate than grep. But tobyink showed the idiom above:
    my $lines =()= <$file>;

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of