http://qs1969.pair.com?node_id=624716


in reply to Split on a new line

Idiomatic perl uses split() when you know what you want to throw away and a regular expression match when you know what you want.

Putting a "zero or more characters from this class" regular expression into split (as in split /\n\r\l*/) effectively splits a string into individual characters - the regex is true between every single character. Your code would get further if you tried split /\n\r\l+/ ....

Using regular expression matches, you could do something like:

#!/usr/bin/perl use strict; use warnings; undef $/; # read whole file at once our $cert = <>; our ($info) = $cert =~ m/X509v3 Basic Constraints:\s+([^\n]+)/; print "Constraints = $info\n";