Re: can't use Scalar ref...

2004-09-16 Thread Jenda Krynicky
From: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]> > it isn't of course only foo. I am parsing ini file, which looks like: > > [ini] > foo=test > bar=foo [%foo%] bar > > and of course, I want to get (after using some config module) > $bar='foo test bar' Is it really necessary to use [%foo%]? I'm

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
JN> Then you need to do 'no strict;' before you do that: JN> no strict; JN> $x =~ s/^\[%([^%]+)%\]$/${$1}/g; JN> use strict; I think turning off strict is bad idea, also, that doesn't work either. It is a bad idea but it is what needs done to use soft references like you are doing. JN> Why not ju

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
Jenda Krynicky [JK], on Thursday, September 16, 2004 at 00:34 (+0200) typed the following: JK> You most probably want to store the data you want to fill into the JK> template in a hash (some call it associative array, please don't): JK> my %data = ( JK>foo =>> 'test', JK>bar =>> '

Re: can't use Scalar ref...

2004-09-15 Thread Gunnar Hjalmarsson
JupiterHost.Net wrote: Ing. Branislav Gerzo wrote: I want change [%foo%] to $foo, so I expect in result 'test' as before defined. Then you need to do 'no strict;' before you do that: no strict; $x =~ s/^\[%([^%]+)%\]$/${$1}/g; use strict; Well, a better suggestion IMO would be that $foo is replaced

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
JupiterHost.Net [JN], on Wednesday, September 15, 2004 at 17:21 (-0500) made these points: JN> Then you need to do 'no strict;' before you do that: JN> no strict; JN> $x =~ s/^\[%([^%]+)%\]$/${$1}/g; JN> use strict; I think turning off strict is bad idea, also, that doesn't work either. JN> Why

Re: can't use Scalar ref...

2004-09-15 Thread Jenda Krynicky
From: "Ing. Branislav Gerzo" <[EMAIL PROTECTED]> > use strict; > use warnings; > > my $foo = 'test'; > my @bar = ( 'foo', '[%foo%]', 'bar' ); > my @list = (); > > foreach my $x (@bar) { > $x =~ s/^\[%([^%]+)%\]$/${$1}/g; > print $x . " "; > } > > -- > ...it gives me compilation

Re: can't use Scalar ref...

2004-09-15 Thread Jeff 'japhy' Pinyan
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

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
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,

Re: can't use Scalar ref...

2004-09-15 Thread Ing. Branislav Gerzo
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

Re: can't use Scalar ref...

2004-09-15 Thread JupiterHost.Net
Ing. Branislav Gerzo wrote: Hi pals, Hello, use strict; use warnings; my $foo = 'test'; my @bar = ( 'foo', '[%foo%]', 'bar' ); my @list = (); foreach my $x (@bar) { $x =~ s/^\[%([^%]+)%\]$/${$1}/g; its esentially doing ${foo} since the string foo is in @bar. that is a soft reference and no