in reply to 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

Sorry...I guess warning wasn't very specific. When I appended your code to my script, it would tell me that the file that was 5 minutes or older was "." or "..", so I guess that would be another couple of files I'd like to ignore. I am vaguely familiar with grep, but can't see how it would help in this scenario. I will read up on glob to see if that will help.
  • Comment on Re: Re: Re: Re: ignore certain files in a folder search, and create a random .txt file

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: ignore certain files in a folder search, and create a random .txt file
by tachyon (Chancellor) on Mar 19, 2004 at 21:43 UTC

    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