develooper Front page | perl.perl5.porters | Postings from December 2004

rewinddir on win32 broken

From:
Larry Shatzer Jr.
Date:
December 22, 2004 14:33
Subject:
rewinddir on win32 broken
Message ID:
20041222200121.GB41272@zippy.zyx.net
Consider the following code:

	opendir DH, "." or die "$!";
	my $counter = 1;
	for (1..10) {
	  sleep(1);
	  open FH, ">./readdir$counter.tmp" or die "$!";
	  print FH "readdir test\n";
	  close FH;
	  rewinddir DH;
	  @results = grep(/^.*\.tmp/,readdir DH);
	  print STDOUT "@results\n";
	  $counter++;
	}
	closedir(DH);

Running this on a unix flavor, it does what you expect. Each loop, 
printing out each filename, including the new ones.

Now run this on win32 (even with cygwin's perl), and it's a different 
story. Nothing will be printed, unless you already have files in the 
current directory that match *.tmp, and then just those, no new ones.

I found this while using POE::Component::DirWatch, which it's author 
mentions this bug on http://poe.perl.org/?Robertbrook

-- Larry

p.s. Sorry if you see this twice. I sent this last email night and did 
not see it this morning. I am subscribed from this address, so was 
just wondering if I made a mistake on my end.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About