From 33bdce126d5133bb3355745f84fcd25051dc73f5 Mon Sep 17 00:00:00 2001 From: rick Date: Fri, 4 Jun 2021 10:55:59 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20deuxi=C3=A8me=20partie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jour08/jour8.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jour08/jour8.pl b/jour08/jour8.pl index f2bd180..638af8c 100644 --- a/jour08/jour8.pl +++ b/jour08/jour8.pl @@ -1,3 +1,4 @@ +#!usr/bin/perl use strict; use warnings; @@ -15,6 +16,19 @@ while () { $total = $total + length($_) - length($tmp); } -close(FH); +print "Le total est : $total.\n"; +seek FH, 0, 0; +$total = 0; +print "Traitement de la deuxième partie…\n"; + +while () { + $tmp = $_; + $tmp =~ s/\\/\\\\/ig; + $tmp =~ s/"/\\"/ig; + chomp($tmp); + chomp($_); + $total = $total + length($tmp) + 2 - length($_); +} print "Le total est : $total.\n"; +close(FH);