Return-Path: Delivered-To: apmail-perl-embperl-archive@www.apache.org Received: (qmail 13652 invoked from network); 4 May 2007 11:14:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 May 2007 11:14:41 -0000 Received: (qmail 24601 invoked by uid 500); 4 May 2007 11:14:47 -0000 Delivered-To: apmail-perl-embperl-archive@perl.apache.org Received: (qmail 24590 invoked by uid 500); 4 May 2007 11:14:47 -0000 Mailing-List: contact embperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list embperl@perl.apache.org Received: (qmail 24579 invoked by uid 99); 4 May 2007 11:14:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 May 2007 04:14:47 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [195.52.11.31] (HELO rt-h3.ecos.de) (195.52.11.31) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 May 2007 04:14:39 -0700 Received: from localhost (localhost [127.0.0.1]) by rt-h3.ecos.de (Postfix) with ESMTP id 900D83F443; Fri, 4 May 2007 13:14:18 +0200 (MEST) Received: from neptun.ecos.de (neptun.ecos.de [194.95.226.11]) by rt-h3.ecos.de (Postfix) with ESMTP id 3FB403F364; Fri, 4 May 2007 13:14:17 +0200 (MEST) Received: from localhost (localhost [127.0.0.1]) by neptun.ecos.de (Postfix) with ESMTP id DA68E78772B; Fri, 4 May 2007 13:14:16 +0200 (MEST) Received: from neptun.ecos.de ([127.0.0.1]) by localhost (Firewall [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02340-06; Fri, 4 May 2007 13:14:16 +0200 (MEST) Received: from lnx1.i.ecos.de (lnx1.i.ecos.de [10.11.11.102]) by neptun.ecos.de (Postfix) with ESMTP id 3271532A1B; Fri, 4 May 2007 13:14:16 +0200 (MEST) Received: from lnx1.i.ecos.de (localhost [127.0.0.1]) by lnx1.i.ecos.de (Postfix) with ESMTP id ED96036F30B; Fri, 4 May 2007 13:14:15 +0200 (CEST) Received: from srvmail1.i.ecos.de (srvmail1.i.ecos.de [10.11.11.111]) by lnx1.i.ecos.de (Postfix) with ESMTP id 8FCE0A807; Fri, 4 May 2007 13:14:15 +0200 (CEST) Received: from srvmail1.i.ecos.de (localhost [127.0.0.1]) by srvmail1.i.ecos.de (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id l44BEETJ021511; Fri, 4 May 2007 13:14:14 +0200 Date: Fri, 4 May 2007 13:14:13 +0200 From: "Gerald Richter - ECOS GmbH" To: embperl@perl.apache.org, yurenli@gmail.com Message-ID: In-Reply-To: Subject: RE: About the regular expression problem x-scalix-Hops: 1 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: von BB5000-Mailfilter X-Virus-Checked: Checked by ClamAV on apache.org HI, > I have a problem when I use regular expression. > The sample code: > [- $_ =3D "One Two Three" -] > [$ if(/(\S+) (\S+) (\S+)/) $] > The words are: [+$1+], [+$2+], [+$3+] > [$ endif $] >=20 > The result should be "The words are: One, Two, Three," But I=20 > got the result "The words are: One, Two,." > After trying, I found that I could just get the match=20 > variables $1 and $2, and the match veriables $3, $4 etc,=20 > could not be used in embperl. >=20 > There is no problem about this in pure perl code such as $_ =3D=20 > "One Two Three"; > if(/(\S+) (\S+) (\S+)/) { > printf "The words are: $1, $2, $3"; > } >=20 Embperl does not do anything with $3, $4 etc. I guess this is a scoping=20 problem. I would write [$ if(($a, $b, $c) =3D (/(\S+) (\S+) (\S+)/)) $] The words are: [+$a+], [+$b+], [+$c+] [$ endif $] That makes sure $1, $2 etc. does not go out of scope Gerald ** Virus checked by BB-5000 Mailfilter ** --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org For additional commands, e-mail: embperl-help@perl.apache.org