RE: Win32 - determining if a file is a directory

2006-06-23 Thread Charles K. Clarkson
Mark Harris wrote: # Always use strict and warnings. use strict; use warnings; : use Win32::File; : $dirspec = "c:\\xfer"; # / is the preferred perl directory separator # (even on windows). my $dirspec = 'c:/xfer'; Following Tom's advice we might do this. : opendir(DS, $dirspec); # Alway

Re: Win32 - determining if a file is a directory

2006-06-23 Thread Tom Phoenix
On 6/23/06, Mark Harris <[EMAIL PROTECTED]> wrote: opendir(DS, $dirspec); You should probably use the "... or die" idiom, in case the opendir fails, much as you would with open. while($fn = readdir(DS)) { if ( -d $fn) The most common error when combining readdir() and the -x family of

Win32 - determining if a file is a directory

2006-06-23 Thread Mark Harris
On a windows xp machine, running the following code with active state perl 5.8.8: use Win32::File; $dirspec = "c:\\xfer"; opendir(DS, $dirspec); while($fn = readdir(DS)) { if ( -d $fn) { print "$fn is a directory\n"; } else { print "$fn is not a directory\n";