regex power
From
Rainer Weikusat@21:1/5 to
All on Thu Apr 14 19:52:33 2022
Assuming that $chain holds the text of a usual certificate chain file,
ie, multiple certificates concatenated, the expression
$chain =~ /(.+?-----END CERTIFICATE-----\n)/gs
will return a list of individual certificates. That's equivalent to a
loop like
my (@certs, $cert);
for (split(/\n/, $chain)) {
$cert .= "$_\n";
if ($_ eq '-----END CERTIFICATE-----') {
push(@certs, $cert);
$cert = '';
}
}
without having to spell out any of the mechanics. Pretty close to "Do
what I mean!" :-)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)