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;
In reply to Searching for and removing multi-line file entries by ibanix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |