Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • thank you very much!! Another argument to learn perl :) Commented May 26, 2021 at 12:30
  • btw, either script variant can easily be turned into a "one-liner". get rid of the while(<>) loop (and the loop's curly-braces) and the print line, join it all up on one line surrounded with single-quotes, and run it with perl -pe. e.g. perl -pe 'my ($match)=m/\b(?:gene|product|sprot)\s+("[^"]*")/; if ($word) {s/\b^Cne_id\s+(?:"[^"]*")/gene_id $match/}' input.txt Commented May 26, 2021 at 12:40