http://qs321.pair.com?node_id=873770


in reply to find & replace a string in perl

Another one (using Regex positive lookahead)

perl -pi -e 's/(?=.*\btest\b)/#/' fileName