Ing. Branislav Gerzo wrote:

JupiterHost.Net [JN], on Wednesday, September 15, 2004 at 16:52
(-0500) made these points:


my $foo = 'test';
my @bar = ( 'foo', '[%foo%]', 'bar' );

JN> The question would be why you're doing ${$1} since nothing in @bar is a JN> reference.

I want change [%foo%] to $foo, so I expect in result 'test' as before
defined.

JN> I think you want:
JN>   $x =~ s/^\[%([^%]+)%\]$/$1/g;

no, that gives me:
foo foo bar

and I don't want to.

Then you need to do 'no strict;' before you do that:

no strict;
$x =~ s/^\[%([^%]+)%\]$/${$1}/g;
use strict;

Why not just use the Template module, it does what it looks like you're trying to do already without reinventing the wheel :)

or if its literally foo

then
for(@bar) { s/\[\%foo\%\]/\Q$foo\E/g; }



HTH :)

Lee.M - JupiterHost.Net

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to