1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| # !/usr/bin/perl
open(f,'<fichier') || die "probleme d'ouverture : $!" ;
my $cp=0;
while(my @ligne[$cp]=<F>){
$cp++;
}
close F;
my $i=0;
my $j=0;
my $permuter=0;
while( $i<$cp){
$j=$i+1;
while( $j<$cp){
if( @ligne[$i]>@ligne[$j]){
$permuter = @ligne [$i];
@ligne[$i]=@ligne[$j];
@ligne[$j]=$permuter;
}
$j++;
}
$i++;
}
close f;
open (f, '>fichiertrie') || die "probleme de creation : $!";
$i=0;
while ($i<$cp){
print f,@ligne[$i];
$i++;
}
close f; |
Partager