Path: ...!eternal-september.org!reader02.eternal-september.org!aioe.org!news.alphanet.ch!alphanet.ch!.POSTED!not-for-mail From: Marc SCHAEFER Newsgroups: fr.comp.usenet.serveurs Subject: Re: Champ cancel-lock multiligne Date: Thu, 19 May 2022 11:21:36 -0000 (UTC) Organization: Posted through ALPHANET Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 19 May 2022 11:21:36 -0000 (UTC) Injection-Info: shakotay.alphanet.ch; posting-account="schaefer"; logging-data="23394"; mail-complaints-to="usenet@alphanet.ch" User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-20-amd64 (x86_64)) Cancel-Lock: sha256:PS4pu3YvO9+GqsEsHnro4b3np4Dl0cEn/lr3aPaQ3UU= Bytes: 3068 Lines: 57 yamo' wrote: > > my %headers; > # for my $line(split(/\s*\n/, $headers)) { > my $previous; > foreach my $line (split(/\s*\n/, $headers)) { for ou foreach c'est la même chose. > if ($line =~ m/^([[:alnum:]-]+):\s+(.*)/) { > $previous = $1; > } elsif ($line =~ m/^\s+(.*)/) { > if (defined($previous)) { > $headers{$previous} .= " " . $1; > } > else { > INN::syslog('notice', 'garbled line: ' . $line); > } > } > } Par contre, il manque des trucs, voici le code complet: my %headers; my $previous; foreach my $line (split(/\s*\n/, $headers)) { if ($line =~ m/^([[:alnum:]-]+):\s+(.*)/) { # assuming low/upcase normalisation by INN $headers{$1} = $2; $previous = $1; } elsif ($line =~ m/^\s+(.*)/) { if (defined($previous)) { $headers{$previous} .= " " . $1; } else { INN::syslog('notice', 'garbled line: ' . $line); } } } (pour tous les entêtes sous la forme Nom: valeur, créer l'association Nom => valeur dans %header, mais également traiter les lignes de continuation) La version de base c'était: my %headers; my $previous; for my $line (split(/\s*\n/, $headers)) { if ($line =~ m/^([[:alnum:]-]+):\s+(.*)/) { # assuming low/upcase normalisation by INN $headers{$1} = $2; } } (pour tous les entêtes sous la forme Nom: valeur, créer l'association Nom => valeur dans %header)