http://www.perlmonks.org?node_id=949468


in reply to forcing list-context

Another way is to unload the readdir call into a temporary array and then call scalar on that e.g.
say scalar(@{[readdir $dh]});
Though this is not as economical (memory wise) as the above solution in Re: forcing list-context