Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I just discovered seekdir, and its kinda broken on win32 (not that I'm 100% sure of how its supposed to behave )
5.006001 seems to behave the most as I expect based on my knowledge of seek
I'm using ActivePerl/mingw-perl on WinXP
#!/usr/bin/perl -- use strict; use warnings; use Data::Dumper; use File::Temp qw/ tempdir /; print $], "\n"; my $dir = tempdir; chdir $dir or die $!; touch( qw/ hi.txt there.txt you.txt / ); opendir my($d), $dir or die $!; foreach my $ix (-1 .. 6) { printf "seekdir(%3d) = %d => %s\n", $ix, seekdir($d, $ix), DD( [ readdir $d ] ); } print '#' x 33,"\n"; sub DD { scalar Data::Dumper->new([@_])->Indent(0)->Useqq(1)->Dump ; } sub touch { for my $file ( @_ ){ open my($fh), '>', $file or die $!; close $fh; } } __END__
5.014001 seekdir( -1) = 1 => $VAR1 = []; seekdir( 0) = 1 => $VAR1 = [".","..","hi.txt","there.txt","you.txt"] +; seekdir( 1) = 1 => $VAR1 = ["","..","hi.txt","there.txt","you.txt"]; seekdir( 2) = 1 => $VAR1 = ["..","hi.txt","there.txt","you.txt"]; seekdir( 3) = 1 => $VAR1 = [".","hi.txt","there.txt","you.txt"]; seekdir( 4) = 1 => $VAR1 = ["","hi.txt","there.txt","you.txt"]; seekdir( 5) = 1 => $VAR1 = ["hi.txt","there.txt","you.txt"]; seekdir( 6) = 1 => $VAR1 = ["i.txt","there.txt","you.txt"]; ################################# 5.012002 seekdir( -1) = 1 => $VAR1 = ["",".","..","hi.txt","there.txt","you.tx +t"]; seekdir( 0) = 1 => $VAR1 = [".","..","hi.txt","there.txt","you.txt"] +; seekdir( 1) = 1 => $VAR1 = ["","..","hi.txt","there.txt","you.txt"]; seekdir( 2) = 1 => $VAR1 = ["..","hi.txt","there.txt","you.txt"]; seekdir( 3) = 1 => $VAR1 = [".","hi.txt","there.txt","you.txt"]; seekdir( 4) = 1 => $VAR1 = ["","hi.txt","there.txt","you.txt"]; seekdir( 5) = 1 => $VAR1 = ["hi.txt","there.txt","you.txt"]; seekdir( 6) = 1 => $VAR1 = ["i.txt","there.txt","you.txt"]; ################################# 5.008009 seekdir( -1) = 1 => $VAR1 = ["",".","..","hi.txt","there.txt","you.tx +t"]; seekdir( 0) = 1 => $VAR1 = [".","..","hi.txt","there.txt","you.txt"] +; seekdir( 1) = 1 => $VAR1 = ["","..","hi.txt","there.txt","you.txt"]; seekdir( 2) = 1 => $VAR1 = ["..","hi.txt","there.txt","you.txt"]; seekdir( 3) = 1 => $VAR1 = [".","hi.txt","there.txt","you.txt"]; seekdir( 4) = 1 => $VAR1 = ["","hi.txt","there.txt","you.txt"]; seekdir( 5) = 1 => $VAR1 = ["hi.txt","there.txt","you.txt"]; seekdir( 6) = 1 => $VAR1 = ["i.txt","there.txt","you.txt"]; ################################# 5.006001 seekdir( -1) = 1 => $VAR1 = [".","..","hi.txt","there.txt","you.txt"] +; seekdir( 0) = 1 => $VAR1 = [".","..","hi.txt","there.txt","you.txt"] +; seekdir( 1) = 1 => $VAR1 = ["..","hi.txt","there.txt","you.txt"]; seekdir( 2) = 1 => $VAR1 = ["hi.txt","there.txt","you.txt"]; seekdir( 3) = 1 => $VAR1 = ["there.txt","you.txt"]; seekdir( 4) = 1 => $VAR1 = ["you.txt"]; seekdir( 5) = 1 => $VAR1 = []; seekdir( 6) = 1 => $VAR1 = []; #################################
|
|---|