#!/usr/bin/perl -w use strict; my $root = "c:\\cl"; my $delim = $^O =~ m/Win32/ ? "\\" : "/"; $root .= $delim unless $root =~ m!\Q$delim\E$!; # ensure we have trailing slash my @dirs = ($root); my @files; for my $path (@dirs){ opendir ( DIR, $path ) or next; # skip dirs we can't read while (my $file = readdir DIR) { next if $file eq '.' or $file eq '..'; # skip the dot files next if -l $path.$file; # skip symbolic links if ( -d $path.$file ) { push @dirs, $path.$file.$delim; # add the dir to dir list } else { push @files, $path.$file; # add the file to file list } } closedir DIR; } do{ local $"=$/; print "Directory list\n@dirs\n\nFile List\n@files\n" };