<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Perl: Handling multiple lines in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863799#M772858</link>
    <description>Im trying to cleanup a few errors in swverify using perl.  I am able to handle the errors when they are on one complete line.  Though, swverify likes to post a majority of the problems on mulitple lines.&lt;BR /&gt;&lt;BR /&gt;   What I have (broken lines)&lt;BR /&gt;&lt;BR /&gt;WARNING: Directory "/usr/share/man/cat7.Z" should have &lt;RETURN&gt;&lt;BR /&gt;owner,uid "bin,2" but the actual owner,uid is "root,0".&lt;BR /&gt;&lt;BR /&gt;   What I want (complete line)&lt;BR /&gt;&lt;BR /&gt;WARNING: Directory "/usr/share/man/cat7.Z" should have owner,uid "bin,2" but the actual owner,uid is "root,0".&lt;BR /&gt;&lt;BR /&gt;Is there anyway to do this in perl?&lt;BR /&gt;&lt;BR /&gt;&lt;/RETURN&gt;</description>
    <pubDate>Fri, 15 Sep 2006 18:11:41 GMT</pubDate>
    <dc:creator>dave.s</dc:creator>
    <dc:date>2006-09-15T18:11:41Z</dc:date>
    <item>
      <title>Perl: Handling multiple lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863799#M772858</link>
      <description>Im trying to cleanup a few errors in swverify using perl.  I am able to handle the errors when they are on one complete line.  Though, swverify likes to post a majority of the problems on mulitple lines.&lt;BR /&gt;&lt;BR /&gt;   What I have (broken lines)&lt;BR /&gt;&lt;BR /&gt;WARNING: Directory "/usr/share/man/cat7.Z" should have &lt;RETURN&gt;&lt;BR /&gt;owner,uid "bin,2" but the actual owner,uid is "root,0".&lt;BR /&gt;&lt;BR /&gt;   What I want (complete line)&lt;BR /&gt;&lt;BR /&gt;WARNING: Directory "/usr/share/man/cat7.Z" should have owner,uid "bin,2" but the actual owner,uid is "root,0".&lt;BR /&gt;&lt;BR /&gt;Is there anyway to do this in perl?&lt;BR /&gt;&lt;BR /&gt;&lt;/RETURN&gt;</description>
      <pubDate>Fri, 15 Sep 2006 18:11:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863799#M772858</guid>
      <dc:creator>dave.s</dc:creator>
      <dc:date>2006-09-15T18:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Handling multiple lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863800#M772859</link>
      <description>&lt;!--!*#--&gt;like this?&lt;BR /&gt;&lt;BR /&gt;m/^warning\b/i and chomp;&lt;BR /&gt;&lt;BR /&gt;that'll remove the newline from lines starting with the word warning (case insensitive), and thus join with the next line. Maybe a bit more elegant would be:&lt;BR /&gt;&lt;BR /&gt;if (m/^warning\b/i) {&lt;BR /&gt;    chomp;           # remove trailing newline&lt;BR /&gt;    s/$/ /;          # add a space&lt;BR /&gt;    $_ .= scalar &amp;lt;&amp;gt;; # join the next available line to the current&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;but as always, TIMTOWTDI&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 15 Sep 2006 18:31:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863800#M772859</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-09-15T18:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Handling multiple lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863801#M772860</link>
      <description>Un(?)fortunately I do not know all to pssoble ways a swverify log might look like, but I doubt all lines with WARNING are split, and I doubt only lines with WARNING are split. Maybe there are ERROR: lines which are split also?&lt;BR /&gt;&lt;BR /&gt;So I suspect the prior solution is not good enough. It will merrily join a complete, non-split, warningn with the next warning.&lt;BR /&gt;We need more info to know how to best solve this.&lt;BR /&gt;We humanoids readily 'see' whether a line is a continuation or a fresh start. The better you can capture that in an algoritme, the better solution you can build.&lt;BR /&gt;&lt;BR /&gt;As a simple example, the single sample line SUGGEST there migh be a space at the end of a split line. Is there always?&lt;BR /&gt;If so, a solution might be:&lt;BR /&gt;&lt;BR /&gt;perl -p "perl -pe "m/^warning\b.* $/i and chomp;" split.log &amp;gt; fixed.log&lt;BR /&gt;&lt;BR /&gt;And to deal with ERRORS and what else you might make that:&lt;BR /&gt;&lt;BR /&gt;perl -p "perl -pe "m/^[A-Z]* $/ and chomp;" split.log &amp;gt; fixed.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe the dangling space at the end does not exist, but each non-split line should start with an uppercase character. In that case the script will have to look back.&lt;BR /&gt;The brute force, solution is to slurp the file into an array and process.&lt;BR /&gt;But you coudl postpone dealing with a line until the next is seen. Something like&lt;BR /&gt;&lt;BR /&gt;---- join.pl ---&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; if (/^[A-Z]/ or eof) {&lt;BR /&gt;# Process line now. Here just print.&lt;BR /&gt;   print "$line";&lt;BR /&gt;# prep for next&lt;BR /&gt;   $line = $_;&lt;BR /&gt; } else {&lt;BR /&gt;# Found a line not starting with uppercase character&lt;BR /&gt;# Assume it was a continuation&lt;BR /&gt;   chomp $line;&lt;BR /&gt;   $line .= " " . $_;&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;# Process final line:&lt;BR /&gt;print "Final: $line";&lt;BR /&gt;-------------&lt;BR /&gt;$ perl join.pl split.log &amp;gt; fixed.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Sep 2006 19:20:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-handling-multiple-lines/m-p/3863801#M772860</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-09-15T19:20:15Z</dc:date>
    </item>
  </channel>
</rss>

