With an array of that size, is it coming from a file? If so, you can do something like this to cut down on memory usage, which will speed up the process. I'm not the expert on regexes, but I believe there is also a way to have the regex compiled only once.
my $counter; while(<INFILE>){ $counter++; if($_ =~ /(\b$input\b)/){ print "Found match on line number $counter\n"; } } -----Original Message----- From: viswanathan sundararajan To: Timothy Johnson Sent: 3/21/02 9:46 PM Subject: RE: Regarding reg. expr Hi, Thanx for ur reply.This is exactly what i am looking for.But if @rootwords is a huge array of length 50000(for example),then it would take some time to find a match.Is there any other way to tackle this? visu --- Timothy Johnson <[EMAIL PROTECTED]> wrote: > > Perhaps something like this: > > my $counter; > foreach(@rootwords){ > $counter++; > $_ .= "\n"; > if($_ =~ /(\b$input\b)/){ > print "Found match on line number $counter\n"; > } > } > > At least I think that's what you're looking for. > > -----Original Message----- > From: viswanathan sundararajan > To: [EMAIL PROTECTED] > Sent: 3/21/02 9:14 PM > Subject: Regarding reg. expr > > Hi group, > I have the following code. > > $in=join("\n",@rootwords); > while($in=~/(\b$input\b)/g) > { > ..... > ..... > } > > Is there any way of finding out the line no where > $input is matched with $in.$in may contains many > instances of $in.I need all those line nos. > > Thanx in advance, > visu > > __________________________________________________ > Do You Yahoo!? > Yahoo! Movies - coverage of the 74th Academy Awards. > http://movies.yahoo.com/ > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > > ------------------------------------------------------------------------ -------- > This email may contain confidential and privileged > material for the sole use of the intended recipient. > > If you are not the intended recipient, please > contact > the sender and delete all copies. __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards. http://movies.yahoo.com/ -------------------------------------------------------------------------------- This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]