Please be informed that Nigel Peck no longer works for this company. He has started his own web development company and will no doubt be in contact in due course.
Regards Mark Crowston >>> "Bruno Negrao - Perl List" <[EMAIL PROTECTED]> 07/10/2002 15:12:34 >>> RE: Regular expressionHi Javeed. This code: foreach (@attt) { /=/ && ( ($out) = (split (/=/))[1] ); } stores the string "HELLO" in the variable $out. Then, if you issue print "$out" you would get a "HELLO". But when I read your e-mail again I realized that you want to store the entire last line. So yoy should use this code instead: foreach (@attt) { /=/ && ( $out = $_ ); } The foreach (@attt) starts a loop storing every line of @attt in a default variable called $_ Then, if the regul. exp "/=/" matches against the default variable $_, the && statement is executed, storing the variable $_ in the variable $out. For clarifying purposes, you could write the same code as: foreach $line (@att) { if ($line =~ /=/){ $out = $line ; print "$out"; } } And if you want to get rid of the blank spaces in the last line, add try this: foreach $line (@attt) { if ($line =~ /=/){ $out = $line ; $out =~ s/\s*//; print "$out"; } } I learnt all this from the O'reilly book "Learning Perl second edition". Tied hugs and warmfull kisses, Bruno Negrão. ----- Original Message ----- From: Javeed SAR To: Bruno Negrao - Perl List Sent: Monday, October 07, 2002 1:21 AM Subject: RE: Regular expression foreach (@attt) { /=/ && ( ($out) = (split (/=/))[1] ); } Can u explain this statement to me? Which is the variable i should use for printing the output? Regards -----Original Message----- From: Bruno Negrao - Perl List [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 6:54 PM To: [EMAIL PROTECTED] Subject: Re: Regular expression > Hi Javeed , > > the last element of the array is $attt[$#attt]. If you have one line per > element, that should do it. Right. This is the easiest way. But, just to answer him, what he could do using regular expression could be something like: foreach (@attt) { /=/ && ( ($out) = (split (/=/))[1] ); } Bruno. > > R > > At 14:24 04/10/2002 +0530, Javeed SAR wrote: > > >I have the following output in array @attt > >I want the last line in a variable $out. > >What should the regular expression be? > > > > > >attribute type "SYNC_CHECK" > > created 04-Oct-02.09:36:42 by javeed.clearuser@BLRK35ED > > "for testing" > > owner: HIS\javeed > > group: HIS\clearuser > > scope: this VOB (ordinary type) > > value type: string > > Attributes: > > SYNC_CHECK = "HELLO" > > > > > >Regards > >j > > > -- > 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] ITM Website Relaunched 15th August 2002 http://www.itm-solutions.co.uk/ ITM Business Solutions Unit 4 Nine Trees Trading Estate Morthen Road Rotherham S66 9JG Reception Tel: 01709 703288 Fax: 01709 701549 Help Desk Tel:01709 530424 Fax: 01709 702159 CONFIDENTIALITY NOTICE: This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]