On Sep 15, Ing. Branislav Gerzo said: >use strict; >use warnings; > >my $foo = 'test'; >my @bar = ( 'foo', '[%foo%]', 'bar' ); >my @list = (); > >foreach my $x (@bar) { > $x =~ s/^\[%([^%]+)%\]$/${$1}/g; > print $x . " "; >}
You should use a hash instead of a set of variables. my %vars = ( foo => 'test', ); Then you do: for (@bar) { s/\[%([^%]+)%]/$vars{$1}/g; } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>