1 2 3 4 5 6 7 8 9 10 11 12 13 14
@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;
@inputFileContent = grep { m/$regex/ } @inputFileContent ;