in reply to Re: Read a list of files into an array
in thread Read a list of files into an array
On Un*x varieties including Linux and MacOS X, the period is just another character which might be in a filename. On those platforms, "*.*" finds only those entries that just happen to include at least one period.
Windows thankfully expects "*" to mean "*.*", so using a single star parameter to glob() is portable on Windows and Un*x varieties both.
my @subdirectories = grep { not /^\.\.?$/ } grep { -d } glob("*");
There is also a -T check which sniffs the head of a file for anything that doesn't smell like text, but I tend not to trust that kind of contents-check. It's not sufficiently clear if it would say true or false for a few UTF-8 or Latin high-bit characters, which I would still call a "text" file.my @files = grep { -f } glob("*");
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read a list of files into an array
by shmem (Chancellor) on Jun 26, 2007 at 10:37 UTC | |
|
Re^3: Read a list of files into an array
by Argel (Prior) on Jun 22, 2007 at 21:33 UTC | |
by halley (Prior) on Jun 25, 2007 at 12:49 UTC | |
| |
|
Re^3: Read a list of files into an array
by Argel (Prior) on Jun 22, 2007 at 23:08 UTC |