#!/usr/bin/perl
my @stuff = (
        'maillog.11.gz',
        'maillog.2.gz',
        'maillog.10.gz',
        'maillog',
        'maillog.1.gz',
        'maillog.3.gz',
);

my @otherstuff = sort {
        (my $numa) = ($a =~ m/\.(\d+)\./);
        (my $numb) = ($b =~ m/\.(\d+)\./);
        $numa <=> $numb || $a cmp $b
} @stuff;

print "original: " . join(', ', @stuff) . "\n";
print "new: " . join(', ', @otherstuff) . "\n";

[EMAIL PROTECTED] ./test.pl
original: maillog.11.gz, maillog.2.gz, maillog.10.gz, maillog,
maillog.1.gz, maillog.3.gz
new: maillog, maillog.1.gz, maillog.2.gz, maillog.3.gz, maillog.10.gz,
maillog.11.gz


HTH

--
Chris Thielen

Easily generate SpamAssassin rules to catch obfuscated spam phrases:
http://www.sandgnat.com/cmos/



ian douglas said:
> My new mailstats.pl script (matt's script with a few tweaks) is giving me
> some grief.
>
> My maillog files are named:
>
> maillog (for today)
> maillog.1.gz
> maillog.2.gz
> etc
> maillog.10.gz
> etc
>
> When Matt's script does the 'sort', it sorts it as:
>
> maillog
> maillog.1.gz
> maillog.10.gz
> maillog.11.gz
> maillog.2.gz
> maillog.3.gz
>
> etc.
>
> Short of renaming my files, does anyone know a Perl tweak to get around
> this, or a tweak to logrotate to make the log number a 2-digit number?
>
> -id
>



-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to