Thanks Gerald. Actually the $1, $2 etc was how I originally tried it.
So the scope of those variables are only within the [$ if $] block? I thought
maybe the scope would be everything from the [$ if $] block to the [$ else $]
block. Guess not, huh? Thanks for the example code.
- Gavin
>From: "Gerald Richter" <[EMAIL PROTECTED]>
>To: "Gavin Spomer" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
>Subject: Re: $& and other special variables
>Date: Fri, 9 Feb 2001 17:50:05 +0100
>MIME-Version: 1.0
>Content-Transfer-Encoding: 7bit
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
>
>
>
>> Does Embperl use the variables $&, $`, $', $1, $2 etc for things other
>than
>> pattern matching?
>
>Embperl doesn't use them in any way.
>
>But they are local, so you have to use them in the same block or assign them
>to a variable first.
>
>BTW $&, $`, $' are very expensive in Perl, it's better to use $1 $2 etc. or
>assign them directly into a list e.g.
>
> [$ if ($pre, $match, $post) = $word =~
>/^(.*?)(bill)(.*?)$/i $]
> [+ $pre +]<b>[+ $match +]</b>[+ $post +]
> [$ else $]
> [+ "$word " +]
> [$ endif $]
>
>Gerald
>
>-------------------------------------------------------------
>Gerald Richter ecos electronic communication services gmbh
>Internetconnect * Webserver/-design/-datenbanken * Consulting
>
>Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
>E-Mail: [EMAIL PROTECTED] Voice: +49 6133 925131
>WWW: http://www.ecos.de Fax: +49 6133 925152
>-------------------------------------------------------------
>
>
>
- Gavin
"People are the worst drivers in the world"
http://www.singlespeedsanonymous.com/
Join PayPal and get FIVE FREE DOLLARS (no joke!):
https://secure.paypal.x.com/refer/pal=gavinspomer%40hotmail.com
... and it's a very usefull account to have!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]