I need a help in writing a PERL SCRIPT that matches a pattern in file and deletes from the second occurrence of the pattern. The file contains output from vmstat and I need to parse the Log with Test::Parser:Vmstat that accepts log in a particular format only. Any alternative to Test::Prser::Vmstat would be a good help

use strict; use warnings; use Test::Parser::Vmstat; my $parser = new Test::Parser::Vmstat or die "Couldn't create Test::Parser::Vmstat object\n"; $parser->parse($ARGV[0] or \*STDIN) or die "Could not parse Vmstat log.\n"; print $parser->to_xml(); FILE procs -----------memory---------- ---swap-- -----io---- --system-- --- +--cpu----- r b swpd free buff cache si so bi bo in cs us s +y id wa st 0 0 0 50101200 234628 9636240 0 0 0 34 10782 6802 + 1 1 98 0 0 1 0 0 50102044 234628 9636276 0 0 0 96 8630 6980 +1 1 98 0 0 1 0 0 50113020 234628 9626112 0 0 0 3092 13393 10324 + 3 1 96 0 0 1 0 0 50111244 234628 9628188 0 0 0 1540 10106 8874 + 2 1 97 0 0 0 0 0 50111256 234628 9628228 0 0 0 0 8674 6961 +1 1 98 0 0 0 0 0 50109884 234628 9628228 0 0 0 280 11290 7593 + 1 1 97 0 0 0 0 0 50110672 234628 9628264 0 0 0 16 8886 7301 +1 1 98 0 0 1 0 0 50110708 234628 9628268 0 0 0 40 11285 6833 + 1 1 98 0 0 NEED TO MATCH AND DELETE procs -----------memory---------- ---swap-- -----io---- --system-- --- +--cpu----- r b swpd free buff cache si so bi bo in cs us s +y id wa st

In reply to Removing matched pattern except the first pattern by rahulruns

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.