#!/usr/bin/perl use Getopt::Long; GetOptions( 'd=s' => \$delete, 'i=s' => \$patternmatch, 'c=s' => \$confile, ) open (FILE, $confile); while () { $line[$.] = $_; if (/$patternmatch/) { delete $line[$_] for ($.-5 .. $.); } } close(FILE); open (OUTPUT, ">$confile"); print (OUTPUT @line); close (OUTPUT);