in reply to Re: Re: Re: Re: ignore certain files in a folder search, and create a random .txt file
in thread ignore certain files in a folder search, and create a random .txt file
You are posting different code to what you are running. You know perl is case sensitive? Anyway next if $File =~ m/^\./ *will* skip* the . and .. dirs. It is better written (more spcific) as next if $File eq '.' or $File eq '..' but it will work. It will skip anything with a leading dot but that is rare on win32 as although you can use it it does not hide the files.
C:\tmp>type test.pl #!/usr/bin/perl -w opendir D, '.' or die $!; while( $file = readdir(D) ) { next if $file =~ m/^\./; print "Got $file\n"; } C:\tmp>test.pl Got A Got bookmark.htm Got inherit.pl Got temp.dir Got temp.pag Got temp0.txt Got temp1.txt Got test.pl C:\tmp>
No dot dirs present. No warnings. Now comment out the next.....
C:\tmp>type test.pl #!/usr/bin/perl -w opendir D, '.' or die $!; while( $file = readdir(D) ) { #next if $file =~ m/^\./; print "Got $file\n"; } C:\tmp>test.pl Got . Got .. Got .foo Got A Got bookmark.htm Got inherit.pl Got temp.dir Got temp.pag Got temp0.txt Got temp1.txt Got test.pl C:\tmp>
cheers
tachyon
|
|---|