$ARGV[0]=$commandfile; $^I=".bak"; while(<>) { foreach $com (keys %hashnew) { if (/$hashnew{com}/../\*\ Exit\ context\ \*/) { s/$com//; } } print WFILE $_; }