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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
use strict;
use warnings;
activerAccents();
my $File = 'C:/Users/baranowp/Documents/2016_01_07_08/facture/facture.txt';
open my $FILE, "<", $File or die "Ouverture impossible de $File $!";
my ($societe, $num_fact, $client, $num_cli, $next_ligne);
$societe = "";
$num_fact = "";
$client = "";
$num_cli = "";
while (<$FILE>) {
chomp;
$societe = $1 if /^Le nom de votre société\s+:\s+(\w+)/;
$num_fact = $1 if /^\s+F A C T U R E n°\s*(\d+)/;
if (/\s+Société et\/ou Nom du client :/) {
$next_ligne = <$FILE>;
$next_ligne = <$FILE>;
$client = $1 if $next_ligne =~ /\s+(\w+)/;
}
$num_cli = $1 if /^N°client\s+:\s+(\d+)/;
#print "$File";
}
print "Société: $societe\nNuméro facture: $num_fact\nClient: $client\nN°client: $num_cli\n";
#########################################
#### Procédure d'ectivation ####
#### des accents ####
#########################################
sub activerAccents {
my $encodage;
# Windows
if ( lc( $^O ) eq 'mswin32' ) {
eval {
my ($codepage) = ( `chcp` =~ m/:\s+(\d+)/ );
$encodage = "cp$codepage";
foreach my $h ( \*STDOUT, \*STDERR, ) {
binmode $h, ":encoding($encodage)";
}
};
}
else {
$encodage = `locale charmap`;
eval {
foreach my $h ( \*STDOUT, \*STDERR, \*STDIN, ) {
binmode $h, ":encoding($encodage)";
}
};
}
return $encodage;
} |
Partager