in reply to Finding files and subdirectories in a directory (was: A couple of ?'s)
Take a look at opendir and readdir, or File::Find if you want to get fancy. :-)
Update: A code example:
#! /usr/bin/perl use strict ; use warnings ; opendir MYDIR, '.' or die $! ; my @allfiles = grep { $_ ne '.' and $_ ne '..' } readdir MYDIR ; my @files = grep { !-d } @allfiles ; my @dirs = grep { -d } @allfiles ; print "Current directory contains " . @files . " files and " . @dirs . " directories.\n" ;
|
|---|