Hi Rob, Yes, I need a tight pattern representation because the buffer I need to parse is slightly complicated than what I had pasted in the mail.
/(FastEthernet|down)/i) gives me an option of "FastEthernet" OR "down". I want something like "FastEthernet" AND "down". How do we give AND operation ? I want my match to be successful only if all the patterns matches. I thought that there might be an easy way to represent them thru Regex and would not have to do any if-else ckecking. Please tell me if you understood my needs or else I will send a bigger mail. Regards Rajeev -----Original Message----- From: Rob Anderson [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 3:13 PM To: [EMAIL PROTECTED] Subject: Re: Need Regex help !! Hi Rajeev, I'm not sure why you feel the need to join your buffer into a big string. >From what you describe couldn't you just process each buffer element one by one? foreach my $buffer_entry (@buff) { if($buffer_entry =~ /(FastEthernet|down)/i) { print $buffer_entry; } } Let us know if your trying to do something more complicated that I've not understood. HTH, Rob "Pandey Rajeev-A19514" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > In short, I have a defined set of pattern that can occur across any number of lines(scalars) in a buffer (array of scalars) and I need to print only those lines(Scalars) that contain the full or partial pattern. For eg. For the buffer @buff (as shown below), I have to find out the occurance of "FastEthernet" and "down". > > I have pasted a code below : > I join the buffer to make a Scalar and then search for the pattern. > > **************************************************************************** **************** > my @buff; > $buff[0] = "Jul 5 03:22:29.635 cst: SNMP: 10.1.0.1 queue overflow, dropping packet\n"; > $buff[1] = " ifEntry.1.13 = 13\n"; > $buff[2] = " ifEntry.2.13 = FastEthernet3/9\n"; > $buff[3] = " ifEntry.3.13 = 6\n"; > $buff[4] = " lifEntry.20.13 = administratively down\n"; > $buff[5] = " ifEntry.2.13 = FastEthernet3/9\n"; > $buff[6] = " ifEntry.3.13 = 6\n"; > $buff[7] = " lifEntry.20.13 = administratively down\n"; > > $temp = join($",@buff); > if($temp =~ /FastEthernet(\n|\d|\w|\.|\/|\s|=)*down/i) { > print "MATCH found\n"; > } > **************************************************************************** ******************* > > Now, that the match has been found, I just want to print only those scalars in @buff which contains the specified pattern. > > The print should be > ifEntry.2.13 = FastEthernet3/9 > lifEntry.20.13 = administratively down > > > Regards > Rajeev > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]