Well, in building my reply, I just learned something. Linux lets you open a directory as a file without an error, but then you can't do anything with it.
Anyway, the answer you're looking for is perldoc -f opendir. This corresponds to the C library opendir/readdir/seekdir/telldir/rewinddir/scandir/closedir family of functions which operate on a DIR* struct, which is very different from a file handle. I think the error message tries to convey that with "dirhandle" language instead of "filehandle".
Meanwhile, I recommend Path::Tiny or Path::Class is you're doing any significant amount of work with browsing file trees. If you can't use modules, there's also the handy 'glob' function with the convenient built-in syntax of my @files= <$dir/*>; Note that that one returns full relative paths instead of just the file names, which is sometimes more useful (and sometimes not).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.