#!/usr/bin/perl -w use scrict; open(INFO,"file.txt"); $cont="001"; while(){ chomp(); if ( /x|(t|T)he/ ) { print "$cont $_";$cont++ } print "\n"; } close INFO; #### /\b\w.\b/