@inputFileContent = map { my $line = $_; my $retval = undef; if ($line =~ m/$regex/){ print "match, removing this line\n"; } else{ print "no match, nothing will happen\n"; $retval = $line; } $retval; } @inputFileContent;