OK....I got things working a bit better now. Thought I'd post the code here for others to view in case I confused way too many people. :-)
#!/usr/bin/perl use strict; use warnings; my $PolicyName = ""; my $PolicyType = ""; my $ActivePolicy = ""; my $ClientServer = ""; open(INFILE, '<mas01_policy_dump.txt'); while(<INFILE>) { chomp; if ( /^\s*$/ ) { # true when the current line is blank next; # No need to process blank lines here } if ( /------------------------------------------------------------ +/) { # Print all the seperators print "$_\n"; next; # No need for further checks } if ($_ =~ "Policy Name") { $PolicyName = $_; # New Policy, pay attention next; } if ($_ =~ "Policy Type") { $PolicyType = $_; next; } if ($_ =~ "Active") { if ($_ =~ "yes") { # Active Policy, we want this stuff $ActivePolicy = $_; print "$PolicyName\n"; print "$PolicyType\n"; print "$ActivePolicy\n"; next; } else { # Inactive policy, skip ahead while(<INFILE>) { if ( /------------------------------------------------ +------------/) { print $_; # CRLF included since no chomp last; } } } } # So should be active policy and non blank line from here if ($_ =~ "HW/OS/Client" ) { # Mutliline!! print "$_\n"; while(<INFILE>) { if ( /^\s*$/ ) { last; } # Blank line = end of lines chomp; print "$_\n"; } next; # I should hit this line only when $_ is blank } }

Now, I'm not done with this just yet, but I wanted to post the code that I have so far that got me through the primary issue I was dealing with at the time.

Thanks,
Dennis

In reply to Re^4: How to print certain lines out of a text file. by sawdustar
in thread How to print certain lines out of a text file. by sawdustar

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.