ibanix has asked for the wisdom of the Perl Monks concerning the following question:
There are many types of[reports] yearlystore = quarterlystore = monthlystore = weeklystore = dailystore = [server1] logfilepath1 = F:\Logfiles\ZWire\Zwire4\split-0\ex*.log servername = Zwire4 logfilepassword = logfileusername = id = a104136320003954 [server2] servername = Zwire6 logfilepath1 = f:\logfiles\zwire\zwire6\split-0\ex*.log id = a104136346513171 logfilepassword = logfileusername = [server3] id = a104136351461256 logfilepath1 = f:\logfiles\zwire\zwire7\split-0\ex*.log logfilepassword = servername = zwire7
entries in these files. I am only concerned with the[header] item = item2 = item3 =
type of entries. I need to remove everything from [serverX] to the next [serverX+1] (but not including it). I will be removing entries based on the contents of the servername = line.[server1] logfilepath1 = F:\Logfiles\ZWire\Zwire4\split-0\ex*.log servername = Zwire4 logfilepassword = logfileusername = id = a104136320003954
Of course, this doesn't help me when I'm only looking for a particular server, or the re-numbering.while (<IN>) { if (/\[server(\d)\]/) { do { $throwaway = <IN>; } until { $throwaway = /\[server(\d)\]/ } +; } else { push @output, $_; } print OUT @output;
All advice appreciated from the wise monks!undef $/; $file = <IN>; # to slurp whole file at once $file =~ s/ # some complex regex //m;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Searching for and removing multi-line file entries
by merlyn (Sage) on Jan 03, 2003 at 00:27 UTC | |
|
Re: Searching for and removing multi-line file entries
by jdporter (Paladin) on Jan 02, 2003 at 22:13 UTC | |
|
Re: Searching for and removing multi-line file entries
by pg (Canon) on Jan 03, 2003 at 00:51 UTC | |
by ibanix (Hermit) on Jan 03, 2003 at 02:51 UTC | |
|
Re: Searching for and removing multi-line file entries
by JamesNC (Chaplain) on Jan 03, 2003 at 06:23 UTC |