substr() c:\> perl -n -e "print if substr($_,0,5) eq q(abcde) && substr($_,-9) eq qq(PARTNAME\n)" c:\somefile.txt>k:\1\somefile.txt