Perl: Trouver le plus grand fichier d’un répertoire

Author:


Download

#!/usr/local/bin/perl
use File::Find;
@ARGV = (".") unless @ARGV;
my ($taille_fichier, $nom_fichier) = (-1, "");
sub lePlusGrand {
    return unless -f && -s _ > $taille_fichier;
    $taille_fichier = -s _;
    $nom_fichier = $File::Find::name;
}
find(\&lePlusGrand, @ARGV);
print "le fichier le plus grand
  de @ARGV  est $nom_fichier ($taille_fichier octets)\n";