#!/usr/bin/perl $foundH = 0; while(<>) { if(/ H / && !$foundH) { s/ H / H1/; $foundH = 1; } print; }