I need help on this one all! I have tried various ways, hash, array, seek. I need to discard all lines that match the __DISCARD__below. The rest I need to save off or print. Thank you!
use strict; use warnings; my (%map,@tmp,$line,$vhost,$next_line); open (MAP, "-|", "/usr/ios/cli/ioscli lsmap -all") or die $!; while (<MAP>) { next if $_ =~ /^$/; next if $_ =~ /--.*/; next if $_ =~ /^SVSA.?/; #push @tmp, (split(" ", $vh, 0 )); if ( /^vhost/i ) { my $pos = tell $fh; my $next_line = <$fh>; seek $fh, $pos, 0; } } __OUT__ vhost0 U9117.MMD.218A8B7-V2-C2 0x0000000 +b VTD vtscsi0 Status Available LUN 0x8100000000000000 Backing device l02duapofdev_r1.58ff94782d7c325acc49a8dd9c04bb1e Physloc Mirrored N/A vhost1 U9117.MMD.218A8B7-V2-C12 0x0000000 +3 VTD NO VIRTUAL TARGET DEVICE FOUND vhost2 U9117.MMD.218A8B7-V2-C13 0x0000000 +4 VTD NO VIRTUAL TARGET DEVICE FOUND vhost8 U9117.MMD.218A8B7-V1-C19 0x0000000 +a VTD vtscsi36 Status Available LUN 0x8100000000000000 Backing device l02dudbofqa2_a1.45b2b49e9b5d2e2a54279a67fab75306 Physloc Mirrored N/A VTD vtscsi37 Status Available LUN 0x8200000000000000 Backing device l02dudbofqa2_r1.0d0657fb7a38e5afe50956bc8fedfb2e Physloc Mirrored N/A __DISCARD__ vhost1 U9117.MMD.218A8B7-V2-C12 0x0000000 +3 VTD NO VIRTUAL TARGET DEVICE FOUND vhost2 U9117.MMD.218A8B7-V2-C13 0x0000000 +4 VTD NO VIRTUAL TARGET DEVICE FOUND

In reply to discard lines after match by teamassociated

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.