wc en version plus intelligente
This commit is contained in:
parent
1c8a6574dd
commit
d5c732de90
@ -1,17 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# This script displays the number of lines in a file
|
||||
|
||||
use strict;
|
||||
|
||||
die "un argument svp ! " if !defined ($ARGV[0]);
|
||||
|
||||
my $i=0;
|
||||
open(P,"< $ARGV[0]") || die "erreur ouverture $!";
|
||||
|
||||
while (<P>)
|
||||
{
|
||||
$i++;
|
||||
}
|
||||
close(P);
|
||||
print "nb de lignes = $i \n";
|
12
perl/wc.pl
Executable file
12
perl/wc.pl
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Utilisation : wc.pl fichier
|
||||
|
||||
open(F, "<$ARGV[0]") || die "Problème d'ouverture de fichier ! ";
|
||||
|
||||
$i = 0 ;
|
||||
$i++ while(<F>);
|
||||
|
||||
close(F);
|
||||
|
||||
print "Nombre de lignes : $i \n";
|
Loading…
Reference in New Issue
Block a user