<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
#
my @personnes;
my ($nom,$prenom,$age,$tri);

do 
{
print "\nTRIER EN FONCTION DE: (nom/prenom/age)\n";
chomp($tri = &lt;STDIN&gt;);

}
until ($tri =~ /^nom|prenom|age$/);

if ($tri =~ /prenom/) { $tri = 1; }
elsif ($tri =~ /nom/) { $tri = 0; }
else {$tri = 2; }


open(INFO,"fichier")  or die("Fichier inexistant");
while (&lt;INFO&gt;)
{	
	($nom,$prenom,$age) = split(":");
	push (@personnes,"$nom $prenom $age");
}

@personnes = 
sort { (split " " , $a )[$tri] cmp
        (split " " , $b )[$tri]
	} @personnes;
print @personnes;



</pre></body></html>