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".
In reply to Re: Unix shell ls vs readdir
by graff
in thread Unix shell ls vs readdir
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |