in reply to forcing list-context

Well, scalar enforces scalar context, not list context. It's the LHS of the assignment that determines context. Putting the readdir in list context is easy:
my ($entries) = readdir $dh;
Note that this not solve your problem. Because you phrased it as an XY problem. You want to solve X, you think Y solves X, so you ask how to solve Y. But Y (putting readdir in list context) does not solve X (finding out the number of entries in a directory). At least, not directly. You can assign the result of readdir to a list and put that assignment in scalar context; this will give you the number of entries in the directory. One way of doing this is:
my $entries = () = readdir $dh;
The parens here indicate an (empty) list.

Replies are listed 'Best First'.
Re^2: forcing list-context
by morgon (Priest) on Jan 23, 2012 at 15:03 UTC
    Well, scalar enforces scalar context, not list context.
    I know that.

    I did not try to enforce list-context with "scalar" but by putting the expression I wanted to evaluate in list-context in parentheses.