#!/usr/bin/perl use strict; use warnings; my $file = '/path/to/file.ext'; my $tmp = $file . '.tmp'; my @unwanted = qw(ICT ProgramVariables nB); open my $in, '<', $file or die $!; open my $out, '>', $tmp or die $!; while( my $line = <$in> ){ next if grep{ $line =~ /\Q$_\E/ }@unwanted; print $out $line; } close $out; close $in; rename $tmp, $file;