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";
    }
}
---

HTH

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]

Sent: 16 April 2002 14:40
To: [EMAIL PROTECTED]
Subject: grep a array element..


Hi all

within a for loop I want to grep/pattern match a variable with each array
element

what would the syntax be ??

many thanks

steve


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to