#!/usr/bin/perl `perl -ni -e 'print; print "adding value=key\n" if $.==3' myfile.txt`; #from command prompt its works fine