#!/usr/bin/perl -i -p # perl foo.pl file.txt if (/^printf\("hello boddy...."\);\s*$/) { $_ .= qq{char *point = new char[10];\n} . qq{printf("complete..\n");\n}; }