Recently I like to use File::Slurp for read/write files and also dir. use File::Slurp; my $dir = shift; my @files = grep { ! /^\./ and -f $dir . "/$_" } read_dir($dir); print join("\n", @files), "\n";
Regards, HT > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Dan Jablonsky > Sent: Thursday, November 30, 2006 12:18 AM > To: perl-win32-users@listserv.ActiveState.com > Subject: readdir problem > > Hi all, > I am trying to read only files in a directory; I need > to jump over the dot files and any subdirectories. > Seems like a simple thing, however with > > opendir(DIR, $dir) || die "can't opendir $dir: $!"; > foreach my $file (readdir DIR) > { > next if (/^\./); # skip over dot files > print "file name is: $file\n"; > } > > I get . and .. and all subdirectories. > > with > > opendir(DIR, $dir) || die "can't opendir $dir: $!"; > foreach my $file (readdir DIR) > { > next if -d $file); # skip over directories > print "file name is: $file\n"; > } > > I skip the dot files but I still get the > subdirectories. Any idea how do I get only the plain > files? > > Thanks, > Dan > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Perl-Win32-Users mailing list > Perl-Win32-Users@listserv.ActiveState.com > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs