in reply to forcing list-context
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.my $entries = () = readdir $dh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: forcing list-context
by morgon (Priest) on Jan 23, 2012 at 15:03 UTC |