#!/usr/bin/perl -w
# Copyright (c) 2007 
# $Id: not versioned$
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# 

use strict;		

# Init

my ($name,$execpath,$suffix);

use File::Basename;

BEGIN {
  # find where the program has been installed
  my $filename = $0;
  eval {$filename = readlink $0 if -l $0};
  ($name,$execpath,$suffix) = fileparse($filename,qw/pl/);
	$execpath =~ s/\\/\//g if $^O =~ /^MSWin/;
}

use lib "$ENV{HOME}/lib/perl";
use lib "$execpath/lib";

my @in = ();
open(IN, "statistiques.html");
while (<IN>) {
	s/<li>/\n$&/g;
	push @in, $_;
}
close IN;

my $n = 0;
foreach (@in) {
	foreach (split('\n',$_)) {
		$n++;
		s/(a href=(["']).*statistiques\/)(.*?)\.(...)(\2)>/$1an-$n.$4$2>/;
		system("mv ../statistiques/$3.$4 ../statistiques/an-$n.$4");
		print $_ . "\n";
	}
}
__END__

# vim:sw=2 ts=2 

