addendum for perl and ls
today handgestrickt wrote about PHP, Perl and systemcalls. later we found a slightly faster Perl script:
here we mix perl with a systemcall to ls, telling it to list all subdirectories recursively and sort by modification time descending. in Perl we just chop the output into pieces.
test.pl
#/usr/bin/perl
$dir = '';
foreach(`ls -Rat1`) {
if(/:$/) { $dir = substr($_,2,-2); }
elsif(/\.(?:jpeg|jpg|jpe|gif|png)$/i) { print $dir.'/'.$_; }
} this does the same task as todays Perl script. the result is now:
perl and ls took: 0.0277252197266 seconds
which is a little bit faster than yesterdays solution in Perl. additionally the code is shorter. unfortunately even this example is slower than the PHP solution.

