in reply to Remove return on multiple lines between 2 characters

TIMTOWTDI... you could open a file handle on a reference to $lines as in-memory file and read from there in paragraph mode:

$lines = "The kernel packages contain the Linux kernel, the core of an +y Linux operating system. Security fixes: * The maximum file offset handling for ext4 file systems could allow a local, unprivileged user to cause a denial of service. (CVE-2011-2695, Important) * IPv6 fragment identification value generation could allow a remote attacker to disrupt a target system's networking, preventing legitimat +e users from accessing its services. (CVE-2011-2699, Important) * A malicious CIFS (Common Internet File System) server could send a specially-crafted response to a directory read request that would resu +lt in a denial of service or privilege escalation on a system that has a CIF +S share mounted. (CVE-2011-3191, Important) "; { local $/ = "\n\n"; open my $fh, "<", \$lines; while( <$fh> ) { if (/\(CVE-/) { s/\n//sg; print ">$_<\n"; } } } __END__ >* The maximum file offset handling for ext4 file systems could allow +alocal, unprivileged user to cause a denial of service. (CVE-2011-269 +5,Important)< >* IPv6 fragment identification value generation could allow a remotea +ttacker to disrupt a target system's networking, preventing legitimat +eusers from accessing its services. (CVE-2011-2699, Important)< >* A malicious CIFS (Common Internet File System) server could send as +pecially-crafted response to a directory read request that would resu +lt ina denial of service or privilege escalation on a system that has + a CIFSshare mounted. (CVE-2011-3191, Important)<
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Remove return on multiple lines between 2 characters
by haukex (Archbishop) on Jul 19, 2017 at 09:50 UTC
    paragraph mode ... local $/ = "\n\n";

    Just wanted to point this out from $/:

    Setting it to "\n\n" means something slightly different than setting to "", if the file contains consecutive empty lines. Setting to "" will treat two or more consecutive empty lines as a single empty line. Setting to "\n\n" will blindly assume that the next input character belongs to the next paragraph, even if it's a newline.
      Just wanted to point this out from $/:

      Good point! But irrelevant in this case, since all newline characters are removed from the matching paragraph. So even if there were multiple leading "\n" characters per record, the output would be the same.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'