Pattern Matchng for only one instance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jain236
    New Member
    • Jul 2007
    • 36

    Pattern Matchng for only one instance

    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
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Code:
    while (<>) {
       if (/(pattern)/) {
          print "found 'pattern' in line number $.\n";
          last;
       }
    }

    Comment

    Working...