On Fri, Jan 24, 2014 at 06:26:58AM -0600, Martin G. McCormick wrote: > This is a perl philosophy question. I need to look for > some files, newest first. If I use the glob directive in perl, I > can fill an array with all the file names that match the pattern > but they aren't sorted in to chronological order. I found a > perlmonks posting in which the same question was asked and the > suggestion was to use something like > > @files = `ls -t filenames*` > > Which, to me, is a perfectly good solution in the unix world. It > probably isn't portable to, say, Windows but it doesn't need to > be in this case. > > I have read perl instructional documentation that warns > about using system("commands") and shell commands so my question > is, what is wrong with that? > > The only thing I can see is that it is not portable and > that since the commands are outside of perl, the results might > change one day. It probably also takes extra CPU cycles but > unless one is doing DSP, who's counting?
This is the correct attitude. As a programmer it is your job to determine, in each instance, where the line lies between beauty, elegance, maintainability, portability, speed, just getting your job done, and a whole bunch of other considerations. In some cases shelling out to ls is exactly the correct thing to do, and when you have decided where your line lies based on your understanding of your requirements, don't let anyone without that understanding tell you otherwise. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/