Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I request the help from perl monks.. With lot of thanks!! Pandeyopen( FILE, "file" ) || die ("The file not there "); #open the file with 50,000 lines (some 1MB memory) @list=<FILE>; # put this in an array. close(DICTIONARY); # close the file $regex="somebla.."; #this is the regex to be matched @match=grep(/$regex/,@list); #the above line returns an array of all lines matched # but I want only first one !! Pity don't know how to # get only that.. print $match[0]; #so I get the first match of the retrned array.. #that is poor .grep has to go through the complet list # although I need the first match only
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fastest pattern match
by lestrrat (Deacon) on Jun 24, 2002 at 19:38 UTC | |
by neilwatson (Priest) on Jun 24, 2002 at 19:43 UTC | |
|
Re: fastest pattern match
by neilwatson (Priest) on Jun 24, 2002 at 19:35 UTC | |
by flounder99 (Friar) on Jun 24, 2002 at 19:50 UTC | |
by japhy (Canon) on Jun 24, 2002 at 22:29 UTC | |
by flounder99 (Friar) on Jun 25, 2002 at 11:53 UTC | |
by frankus (Priest) on Jun 25, 2002 at 12:40 UTC | |
by d4vis (Chaplain) on Jun 24, 2002 at 20:11 UTC | |
by Fastolfe (Vicar) on Jun 24, 2002 at 20:25 UTC | |
|
Re: fastest pattern match
by Cody Pendant (Prior) on Jun 25, 2002 at 04:05 UTC |