RE: grep a array element..

2002-04-16 Thread Steven_Massey
IL PROTECTED]>, "Beginners (E-mail)" <[EMAIL PROTECTED]> Subject: RE: grep a array element.. Please do... I thought using qr// to store REs in variables speed up since it gets compiled once instead of over and over again. > -Original Message- > From: Jeff &

RE: grep a array element..

2002-04-16 Thread Nikola Janceski
Janceski > Cc: '[EMAIL PROTECTED]'; Beginners (E-mail) > Subject: RE: grep a array element.. > > > On Apr 16, Nikola Janceski said: > > >Yes but only if you are looking for that pattern.. if > you wanted to add > >something like "sedan" then

RE: grep a array element..

2002-04-16 Thread Jeff 'japhy' Pinyan
On Apr 16, Nikola Janceski said: >Yes but only if you are looking for that pattern.. if you wanted to add >something like "sedan" then you need to use // but the qr would speed up the >compile when using a $var in the //; > >if($element =~ $lookfor) { ## works if $lookfor = qr/car/; the same

RE: grep a array element..

2002-04-16 Thread Jeff 'japhy' Pinyan
On Apr 16, David Gray said: >> my $lookfor = qr/car/; # this is faster and you don't even >> need to put in the // > >> > if ($element =~ /$lookfor/) { > >Are you saying the if inside the foreach could be written as: > >if($element =~ $lookfor) { > >If the search string is defined with qr//?

RE: grep a array element..

2002-04-16 Thread Nikola Janceski
f($element =~ /sedan $lookfor/) { ## works faster if $lookfor = qr/car/; than if $lookfor = "car"; > -Original Message- > From: David Gray [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 16, 2002 11:41 AM > To: [EMAIL PROTECTED]; 'Nikola Janceski' > Sub

RE: grep a array element..

2002-04-16 Thread David Gray
> uh... > > my $lookfor = qr/car/; # this is faster and you don't even > need to put in the // > > --- > > use strict; > > > > my @array = qw(car bus caravan bike cart); > > > > my $lookfor = "car"; > > > > foreach my $element (@array) { > > if ($element =~ /$lookfor/) { > > prin

RE: grep a array element..

2002-04-16 Thread Nikola Janceski
uh... my $lookfor = qr/car/; # this is faster and you don't even need to put in the // > -Original Message- > From: John Edwards [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 16, 2002 9:42 AM > To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] > Sub

RE: grep a array element..

2002-04-16 Thread John Edwards
You mean something like this? --- use strict; my @array = qw(car bus caravan bike cart); my $lookfor = "car"; foreach my $element (@array) { if ($element =~ /$lookfor/) { print "Found a match!! => $element\n"; } else { print "$lookfor doesn't match $element\n"; } }