in reply to Re^3: How to print certain lines out of a text file.
in thread How to print certain lines out of a text file.

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