in reply to Unix shell ls vs readdir
Aside from being all Perl, is there any other reason to use the "readdir" option over the "ls" option?EDIT: Just realized that there is a slim chance in the "ls" option of getting a bad element on the list. Because I'm only parsing ls output, a funny file name could mess up that parsing. Whereas with the "readdir" option, I'm certain of what I'm getting. That's actually a very good reason to stick with the all Perl "readdir" option.
Right. Apart from the fact that "ls" might behave with minor but annoying differences on different systems, it's generally trickier / less reliable to parse its text output than to pull file names via direct-access to directory entries using readdir (and link target names via direct-access to symlinks using readlink).
I have seen file names on unix systems with non-ascii characters and ascii control characters (including line-feed, carriage-return, etc), all of which can be very disorienting when viewed via "ls".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unix shell ls vs readdir
by Anonymous Monk on Feb 06, 2012 at 12:06 UTC | |
by graff (Chancellor) on Feb 07, 2012 at 02:10 UTC | |
by GrandFather (Saint) on Feb 07, 2012 at 21:22 UTC |