in reply to Re^4: How to print certain lines out of a text file.
in thread How to print certain lines out of a text file.
#!/usr/bin/perl use strict; use warnings; my $PolicyName = ""; my $PolicyType = ""; my $ActivePolicy = ""; my $ClientServer = ""; open(INFILE, '<mas01_policy_dump.txt'); while(<INFILE>) { if ($_ =~ "Policy Name") { $PolicyName = $_; #print $line; } if ($_ =~ "Policy Type") { $PolicyType = $_; } if (($_ =~ "Active") && ($_ =~ "yes")) { $ActivePolicy = $_; print $PolicyName; print $PolicyType; print $ActivePolicy; } if ($_ =~ "HW/OS/Client") { while ($_) { next if /^$/; $ClientServer = $_; print $ClientServer; next; } } next; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: How to print certain lines out of a text file.
by graff (Chancellor) on Jul 31, 2010 at 23:08 UTC |