in reply to Re: Reading
in thread Reading from ls-lrt (was: Reading)

You may want to move the readdir DIR step to a point just prior to the sort so that you can properly filter the directory there... perhaps using a glob or File::Find. This way we can explicitly include only the file types we want, rather than excluding the . and .. (what about .bash_history or such files?) inside the for loop.
  • Comment on (ichimunki) suggestion regarding Perl-ized 'ls -lrt'

Replies are listed 'Best First'.
Re: Re: Re: Reading
by mr.nick (Chaplain) on Feb 05, 2001 at 20:55 UTC
    I presume that files beginning with a dot where still eligable for transfer as he didn't say anything about that. But if he's mirroring an FTP site, I suppose a
    next if $x=~/^\./;
    would be appropriate (and take care of the directory stuff).
    You be right, ichimunki, by using the example of 'ls -ltr', it doesn't include dot files ;)
      Actually, he is using 'ls -lrt'. If I'm not mistaken this will not display .files in the list, so we need that. I'd rather not include any invalid files in my sort process to begin with, hence my suggestion. In fact, if we start out with the correct file list and sort it based on stat, then we just need to do @return_list = @sort_list[0..4] without looping through the list at all.