foreach(f1) { chomp; $line=split(/\s*\{\d+\}/,$_); foreach(f2) $_="CLAUSE_START=$line"; if($_ eq EOF) { $_="CLAUSE_END=$line"; } }