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

rewinddir on win32 broken

Larry Shatzer Jr.
December 22, 2004 14:33
rewinddir on win32 broken
Message ID:
Consider the following code:

	opendir DH, "." or die "$!";
	my $counter = 1;
	for (1..10) {
	  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";

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

-- 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. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About