in reply to array of files in directory
The problem i faced was that the -d option didnt work on windows. i did it by looking at the numbers of stat... the second field "file mode" does the trick. When i switched to nix i had to change the numbers and that was it
#!/usr/bin/perl my @allfiles; $dir = "..\\"; opendir (THISDIR, $dir) or die "Can't read dir"; @temp = grep { not /^[.][.]?\z/ } readdir THISDIR; foreach $l(@temp){ (@status[0..12]) = stat($dir.$l); if ($status[2] == 16895){ #windows dir will $alldir[++$#alldir] = $l; print "\nDirectory = $l"; }else{ print "\nFile = $l"; } }
i know there is a better solution but this was my make fast one. Note that this does not deal with symbolic links
|
|---|