Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

(dkubb) Re: (2) Is readdir ever deterministic?

by dkubb (Deacon)
on Sep 17, 2001 at 19:43 UTC ( #112881=note: print w/ replies, xml ) Need Help??


in reply to Is readdir ever deterministic?

If you're trying to write cross-platform code you may want to keep something else in mind - another thing that isn't absolutely gauranteed is the characters the OS uses to represent the current and the parent directories.

I use File::Spec::Functions's no_upwards() function to check and see if the filename is the current working or parent directory or not:

#!/usr/bin/perl -wT use strict; use File::Spec::Functions qw(catdir rootdir no_upwards); use constant START_DIR => catdir(rootdir, qw(users foo)); opendir DIR, START_DIR or die 'Could not open directory ', START_DIR, ": $!"; while( defined(my $file = readdir DIR) ) { next unless no_upwards($file); print "$file\n"; #...do something with $file } closedir DIR;


Comment on (dkubb) Re: (2) Is readdir ever deterministic?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://112881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2014-07-30 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls