Connecting Tech Pros Worldwide Forums | Help | Site Map

Pattern Matchng for only one instance

Member
 
Join Date: Jul 2007
Posts: 35
#1: Jun 26 '08
Hi all,
i have a text file in which i am searching for a pattern which appears many times, but i just want to search for the 1 instance only and it should skip all other similar pattern.

your help will be appreciated and thanking you in advance

jain

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Jun 26 '08

re: Pattern Matchng for only one instance


Expand|Select|Wrap|Line Numbers
  1. while (<>) {
  2.    if (/(pattern)/) {
  3.       print "found 'pattern' in line number $.\n";
  4.       last;
  5.    }
  6. }  
Reply