I need to find the number of entries in a directory, so I do this:
What bugs me is the "grep {1}"-thing that I do for the sole purpose of forcing a list-context on the readdir as doing simpy a $entries = scalar (readdir $dh) (i.e. putting paentheses around the call) does not do the trick...opendir my $dh, $dir or die $!; my $entries = grep {1} readdir $dh;
So I wonder now: What is the idiomatic way to force list-context?
Many thanks!
In reply to forcing list-context by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |