#!/usr/local/bin/perl
use strict;
$|++;
my $dir = "../../logs/";
my $output = "../stats/current.txt";
#read the dir and put all files to a list
opendir DIR, $dir || die "blah!";
my @allfiles = readdir DIR;
close DIR;
# remove those files from list that don't seem to be logfiles
my @logs = grep /^\d{6}.?\.log$/i, @allfiles;
# sort in a way you like
my @sorted = map{ $_->[0] }
sort {$a->[1] cmp $b->[1]}
map { [ substr($_,2,2).substr($_,0,2).substr($_,4)] }
@logs;
# start output
open OUTPUT, ">$output" || die "blah!";
print OUTPUT join "\n", @logs;
close OUTPUT;
# end output
|