File "cherche.pl"
Full Path: /home/analogde/www/Tableau/andre/PERL/cherche.pl
File size: 521 bytes
MIME-type: text/x-perl
Charset: utf-8
#!/usr/bin/perl
print("Quel mot voulez-vous rechercher :");
$cherche = <STDIN>;
chop($cherche);
$ligne="0";
$sum="0";
$cond="0";
while(<>){
$cond=$sum;
$ligne +=1;
$sum += (s/\b$cherche\b/$cherche/g);
if($cond != $sum){
print("Ligne $ligne ==> ");
print("$sum\n");
};
};
print("----------------------------------------------------\n");
print("Votre fichier contient $sum fois le mot \'$cherche\'\n");
while ($_=<>) {
split;
foreach $w (@_) {
$nb{$w}++;
}
}
foreach $w (keys %nb) {
print ``$w\t$nb{$w}\n'';
}