Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <a href="https://metacpan.org/pod/perlfunc#readdir-DIRHANDLE" rel="nofollow noreferrer">readdir</a> or <a href="https://metacpan.org/pod/perlfunc#glob-EXPR" rel="nofollow noreferrer">glob</a>.</p> <p>Or, you can use a module such as <a href="https://metacpan.org/pod/Path::Class::Dir#list-dir-children" rel="nofollow noreferrer">Path::Class</a>:</p> <blockquote> <p>Ordinarily <code>children()</code> will not include the self and parent entries . and .. (or their equivalents on non-Unix systems), because that's like I'm-my-own-grandpa business. If you do want all directory entries including these special ones, pass a true value for the all parameter:</p> <pre><code>@c = $dir-&gt;children(); # Just the children @c = $dir-&gt;children(all =&gt; 1); # All entries </code></pre> <p>In addition, there's a no_hidden parameter that will exclude all normally "hidden" entries - on Unix this means excluding all entries that begin with a dot (<code>.</code>):</p> </blockquote> <pre><code>@c = $dir-&gt;children(no_hidden =&gt; 1); # Just normally-visible entries </code></pre> <p>Or, <a href="https://metacpan.org/pod/Path::Tiny#children" rel="nofollow noreferrer">Path::Tiny</a>:</p> <blockquote> <pre><code>@paths = path("/tmp")-&gt;children; @paths = path("/tmp")-&gt;children( qr/\.txt$/ ); </code></pre> <p>Returns a list of <code>Path::Tiny</code> objects for all files and directories within a directory. Excludes <code>"."</code> and <code>".."</code> automatically.</p> <p>If an optional <code>qr//</code> argument is provided, it only returns objects for child names that match the given regular expression. Only the base name is used for matching:</p> </blockquote> <pre><code>@paths = path("/tmp")-&gt;children( qr/^foo/ ); # matches children like the glob foo* </code></pre> <p>Getting the list of directory entries into an array wastes some memory (as opposed to getting one file name at a time), but with only a few hundred files, this is unlikely to be an issue.</p> <p><code>Path::Class</code> is portable to operating systems other than *nix and Windows. On the other hand, AFAIK, its instances use more memory than do <code>Path::Tiny</code> instances.</p> <p>If memory is an issue, you are better off using <code>readdir</code> in a <code>while</code> loop.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload